feat: 최근 종료한 라이브 20개 가져오는 API 추가
This commit is contained in:
parent
d98268f809
commit
a3aad9d2c9
|
@ -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
|
||||||
|
)
|
|
@ -291,4 +291,7 @@ class LiveRoomController(
|
||||||
|
|
||||||
ApiResponse.ok(service.getHeartList(roomId))
|
ApiResponse.ok(service.getHeartList(roomId))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/latest-finished-live")
|
||||||
|
fun getLatestFinishedLive() = run { ApiResponse.ok(service.getLatestFinishedLive()) }
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,6 +60,7 @@ interface LiveRoomQueryRepository {
|
||||||
fun getTotalHeartCount(roomId: Long): Int?
|
fun getTotalHeartCount(roomId: Long): Int?
|
||||||
fun getLiveRoomCreatorId(roomId: Long): Long?
|
fun getLiveRoomCreatorId(roomId: Long): Long?
|
||||||
fun getHeartList(roomId: Long): List<GetLiveRoomHeartListItem>
|
fun getHeartList(roomId: Long): List<GetLiveRoomHeartListItem>
|
||||||
|
fun getLatestFinishedLive(): List<LiveRoom>
|
||||||
}
|
}
|
||||||
|
|
||||||
class LiveRoomQueryRepositoryImpl(
|
class LiveRoomQueryRepositoryImpl(
|
||||||
|
@ -380,4 +381,18 @@ class LiveRoomQueryRepositoryImpl(
|
||||||
.orderBy(useCan.can.add(useCan.rewardCan).sum().desc())
|
.orderBy(useCan.can.add(useCan.rewardCan).sum().desc())
|
||||||
.fetch()
|
.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()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ import kr.co.vividnext.sodalive.can.use.UseCanCalculateStatus
|
||||||
import kr.co.vividnext.sodalive.common.SodaException
|
import kr.co.vividnext.sodalive.common.SodaException
|
||||||
import kr.co.vividnext.sodalive.explorer.ExplorerQueryRepository
|
import kr.co.vividnext.sodalive.explorer.ExplorerQueryRepository
|
||||||
import kr.co.vividnext.sodalive.extensions.convertLocalDateTime
|
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.FcmEvent
|
||||||
import kr.co.vividnext.sodalive.fcm.FcmEventType
|
import kr.co.vividnext.sodalive.fcm.FcmEventType
|
||||||
import kr.co.vividnext.sodalive.live.reservation.LiveReservationRepository
|
import kr.co.vividnext.sodalive.live.reservation.LiveReservationRepository
|
||||||
|
@ -1296,4 +1297,17 @@ class LiveRoomService(
|
||||||
totalHeart = heartList.sumOf { it.heart }
|
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()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue