feat: 라이브 메인 API
- 기존에 섹션별로 따로따로 호출하던 것을 하나로 합쳐서 호출할 수 있도록 API 추가
This commit is contained in:
@@ -3,15 +3,21 @@ package kr.co.vividnext.sodalive.live.recommend
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import kr.co.vividnext.sodalive.member.MemberRole
|
||||
import kr.co.vividnext.sodalive.member.block.BlockMemberRepository
|
||||
import org.springframework.cache.annotation.Cacheable
|
||||
import org.springframework.data.domain.Pageable
|
||||
import org.springframework.stereotype.Service
|
||||
import org.springframework.transaction.annotation.Transactional
|
||||
|
||||
@Service
|
||||
class LiveRecommendService(
|
||||
private val repository: LiveRecommendRepository,
|
||||
private val blockMemberRepository: BlockMemberRepository
|
||||
) {
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
@Cacheable(
|
||||
cacheNames = ["cache_ttl_3_hours"],
|
||||
key = "'getRecommendLive:' + (#member ?: 'guest')"
|
||||
)
|
||||
fun getRecommendLive(member: Member?): List<GetRecommendLiveResponse> {
|
||||
return repository.getRecommendLive(
|
||||
isBlocked = {
|
||||
|
@@ -8,7 +8,6 @@ data class GetLatestFinishedLiveQueryResponse @QueryProjection constructor(
|
||||
val memberId: Long,
|
||||
val nickname: String,
|
||||
val profileImageUrl: String,
|
||||
val title: String,
|
||||
val updatedAt: LocalDateTime
|
||||
)
|
||||
|
||||
@@ -16,14 +15,13 @@ data class GetLatestFinishedLiveResponse(
|
||||
val memberId: Long,
|
||||
val nickname: String,
|
||||
val profileImageUrl: String,
|
||||
val title: String,
|
||||
val timeAgo: String
|
||||
val timeAgo: String,
|
||||
var isFollowing: Boolean = false
|
||||
) {
|
||||
constructor(response: GetLatestFinishedLiveQueryResponse) : this(
|
||||
response.memberId,
|
||||
response.nickname,
|
||||
response.profileImageUrl,
|
||||
response.title,
|
||||
response.updatedAt.getTimeAgoString()
|
||||
)
|
||||
}
|
||||
|
@@ -404,7 +404,6 @@ class LiveRoomQueryRepositoryImpl(
|
||||
member.id,
|
||||
member.nickname,
|
||||
member.profileImage.prepend("/").prepend(cloudFrontHost),
|
||||
liveRoom.title,
|
||||
liveRoom.updatedAt
|
||||
)
|
||||
)
|
||||
|
@@ -56,6 +56,7 @@ import kr.co.vividnext.sodalive.member.MemberRole
|
||||
import kr.co.vividnext.sodalive.member.block.BlockMemberRepository
|
||||
import kr.co.vividnext.sodalive.utils.generateFileName
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
import org.springframework.cache.annotation.Cacheable
|
||||
import org.springframework.context.ApplicationEventPublisher
|
||||
import org.springframework.data.domain.Pageable
|
||||
import org.springframework.data.repository.findByIdOrNull
|
||||
@@ -113,6 +114,7 @@ class LiveRoomService(
|
||||
) {
|
||||
private val tokenLocks: MutableMap<Long, ReentrantReadWriteLock> = mutableMapOf()
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
fun getRoomList(
|
||||
dateString: String?,
|
||||
status: LiveRoomStatus,
|
||||
@@ -1297,6 +1299,11 @@ class LiveRoomService(
|
||||
)
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
@Cacheable(
|
||||
cacheNames = ["cache_ttl_10_minutes"],
|
||||
key = "'getLatestFinishedLive:' + (#member ?: 'guest')"
|
||||
)
|
||||
fun getLatestFinishedLive(member: Member?): List<GetLatestFinishedLiveResponse> {
|
||||
return repository.getLatestFinishedLive()
|
||||
.filter {
|
||||
|
Reference in New Issue
Block a user