feat: 최근 종료한 라이브 20개 가져오는 API 추가

This commit is contained in:
Klaus 2025-07-18 14:15:03 +09:00
parent d98268f809
commit a3aad9d2c9
4 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,9 @@
package kr.co.vividnext.sodalive.live.room
data class GetLatestFinishedLiveResponse(
val memberId: Long,
val nickname: String,
val profileImageUrl: String,
val title: String,
val timeAgo: String
)

View File

@ -291,4 +291,7 @@ class LiveRoomController(
ApiResponse.ok(service.getHeartList(roomId))
}
@GetMapping("/latest-finished-live")
fun getLatestFinishedLive() = run { ApiResponse.ok(service.getLatestFinishedLive()) }
}

View File

@ -60,6 +60,7 @@ interface LiveRoomQueryRepository {
fun getTotalHeartCount(roomId: Long): Int?
fun getLiveRoomCreatorId(roomId: Long): Long?
fun getHeartList(roomId: Long): List<GetLiveRoomHeartListItem>
fun getLatestFinishedLive(): List<LiveRoom>
}
class LiveRoomQueryRepositoryImpl(
@ -380,4 +381,18 @@ class LiveRoomQueryRepositoryImpl(
.orderBy(useCan.can.add(useCan.rewardCan).sum().desc())
.fetch()
}
override fun getLatestFinishedLive(): List<LiveRoom> {
return queryFactory
.selectFrom(liveRoom)
.innerJoin(liveRoom.member, member)
.where(
liveRoom.isActive.isFalse
.and(liveRoom.channelName.isNotNull)
)
.groupBy(liveRoom.member.id)
.orderBy(liveRoom.updatedAt.max().desc())
.limit(20)
.fetch()
}
}

View File

@ -19,6 +19,7 @@ import kr.co.vividnext.sodalive.can.use.UseCanCalculateStatus
import kr.co.vividnext.sodalive.common.SodaException
import kr.co.vividnext.sodalive.explorer.ExplorerQueryRepository
import kr.co.vividnext.sodalive.extensions.convertLocalDateTime
import kr.co.vividnext.sodalive.extensions.getTimeAgoString
import kr.co.vividnext.sodalive.fcm.FcmEvent
import kr.co.vividnext.sodalive.fcm.FcmEventType
import kr.co.vividnext.sodalive.live.reservation.LiveReservationRepository
@ -1296,4 +1297,17 @@ class LiveRoomService(
totalHeart = heartList.sumOf { it.heart }
)
}
fun getLatestFinishedLive(): List<GetLatestFinishedLiveResponse> {
return repository.getLatestFinishedLive()
.map {
GetLatestFinishedLiveResponse(
memberId = it.member!!.id!!,
nickname = it.member!!.nickname,
profileImageUrl = "$cloudFrontHost/${it.member!!.profileImage}",
title = it.title,
timeAgo = it.updatedAt!!.getTimeAgoString()
)
}
}
}