From dd0b751a43e04e0e6cfe9c4de78705db8d2fe389 Mon Sep 17 00:00:00 2001 From: Klaus Date: Fri, 20 Sep 2024 00:56:27 +0900 Subject: [PATCH] =?UTF-8?q?=EB=9D=BC=EC=9D=B4=EB=B8=8C=20-=20repository=20?= =?UTF-8?q?=ED=98=B8=EC=B6=9C=20=EB=A9=94=EC=86=8C=EB=93=9C=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=EB=A1=9C=20?= =?UTF-8?q?=EB=84=98=EA=B8=B0=EB=8D=98=20cloudFrontHost=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sodalive/live/room/LiveRoomController.kt | 2 +- .../sodalive/live/room/LiveRoomRepository.kt | 16 +++++++++++----- .../sodalive/live/room/LiveRoomService.kt | 6 +++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/live/room/LiveRoomController.kt b/src/main/kotlin/kr/co/vividnext/sodalive/live/room/LiveRoomController.kt index 18c3a01..e37f38f 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/live/room/LiveRoomController.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/live/room/LiveRoomController.kt @@ -232,7 +232,7 @@ class LiveRoomController( ) = run { if (member == null) throw SodaException("로그인 정보를 확인해주세요.") - ApiResponse.ok(service.getDonationStatus(roomId, member)) + ApiResponse.ok(service.getDonationStatus(roomId)) } @PostMapping("/quit") diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/live/room/LiveRoomRepository.kt b/src/main/kotlin/kr/co/vividnext/sodalive/live/room/LiveRoomRepository.kt index c4aeac8..7526bf7 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/live/room/LiveRoomRepository.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/live/room/LiveRoomRepository.kt @@ -11,6 +11,7 @@ import kr.co.vividnext.sodalive.live.room.QQuarterLiveRankings.quarterLiveRankin import kr.co.vividnext.sodalive.live.room.donation.GetLiveRoomDonationItem import kr.co.vividnext.sodalive.live.room.donation.QGetLiveRoomDonationItem import kr.co.vividnext.sodalive.member.QMember.member +import org.springframework.beans.factory.annotation.Value import org.springframework.data.jpa.repository.JpaRepository import org.springframework.stereotype.Repository import java.time.LocalDateTime @@ -47,13 +48,18 @@ interface LiveRoomQueryRepository { fun getLiveRoom(id: Long): LiveRoom? fun getLiveRoomAndAccountId(roomId: Long, memberId: Long): LiveRoom? - fun getRecentRoomInfo(memberId: Long, cloudFrontHost: String): GetRecentRoomInfoResponse? + fun getRecentRoomInfo(memberId: Long): GetRecentRoomInfoResponse? fun getDonationTotal(roomId: Long): Int? - fun getDonationList(roomId: Long, cloudFrontHost: String): List + fun getDonationList(roomId: Long): List fun getRoomActiveAndChannelNameIsNotNull(memberId: Long): List } -class LiveRoomQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : LiveRoomQueryRepository { +class LiveRoomQueryRepositoryImpl( + private val queryFactory: JPAQueryFactory, + + @Value("\${cloud.aws.cloud-front.host}") + private val cloudFrontHost: String +) : LiveRoomQueryRepository { override fun getLiveRoomListNow( offset: Long, limit: Long, @@ -200,7 +206,7 @@ class LiveRoomQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : L .fetchFirst() } - override fun getRecentRoomInfo(memberId: Long, cloudFrontHost: String): GetRecentRoomInfoResponse? { + override fun getRecentRoomInfo(memberId: Long): GetRecentRoomInfoResponse? { return queryFactory .select( Projections.constructor( @@ -234,7 +240,7 @@ class LiveRoomQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : L .fetchOne() } - override fun getDonationList(roomId: Long, cloudFrontHost: String): List { + override fun getDonationList(roomId: Long): List { return queryFactory .select( QGetLiveRoomDonationItem( diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/live/room/LiveRoomService.kt b/src/main/kotlin/kr/co/vividnext/sodalive/live/room/LiveRoomService.kt index 02c9b7e..0e1621b 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/live/room/LiveRoomService.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/live/room/LiveRoomService.kt @@ -690,7 +690,7 @@ class LiveRoomService( } fun getRecentRoomInfo(member: Member): GetRecentRoomInfoResponse { - return repository.getRecentRoomInfo(memberId = member.id!!, cloudFrontHost = cloudFrontHost) + return repository.getRecentRoomInfo(memberId = member.id!!) ?: throw SodaException("최근 데이터가 없습니다.") } @@ -1166,9 +1166,9 @@ class LiveRoomService( } } - fun getDonationStatus(roomId: Long, member: Member): GetLiveRoomDonationStatusResponse { + fun getDonationStatus(roomId: Long): GetLiveRoomDonationStatusResponse { val room = repository.getLiveRoom(roomId) ?: throw SodaException("잘못된 요청입니다.") - val donationList = repository.getDonationList(roomId = room.id!!, cloudFrontHost = cloudFrontHost) + val donationList = repository.getDonationList(roomId = room.id!!) val totalCan = donationList.sumOf { it.can } return GetLiveRoomDonationStatusResponse(