라이브 방
- 현재 라이브 하트 랭킹 API
This commit is contained in:
		| @@ -283,4 +283,14 @@ class LiveRoomController( | ||||
|  | ||||
|         ApiResponse.ok(service.getTotalHeartCount(roomId)) | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/{id}/heart-list") | ||||
|     fun heartList( | ||||
|         @PathVariable("id") roomId: Long, | ||||
|         @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member? | ||||
|     ) = run { | ||||
|         if (member == null) throw SodaException("로그인 정보를 확인해주세요.") | ||||
|  | ||||
|         ApiResponse.ok(service.getHeartList(roomId)) | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -12,6 +12,8 @@ import kr.co.vividnext.sodalive.live.room.QLiveRoom.liveRoom | ||||
| import kr.co.vividnext.sodalive.live.room.QQuarterLiveRankings.quarterLiveRankings | ||||
| import kr.co.vividnext.sodalive.live.room.donation.GetLiveRoomDonationItem | ||||
| import kr.co.vividnext.sodalive.live.room.donation.QGetLiveRoomDonationItem | ||||
| import kr.co.vividnext.sodalive.live.room.like.GetLiveRoomHeartListItem | ||||
| import kr.co.vividnext.sodalive.live.room.like.QGetLiveRoomHeartListItem | ||||
| import kr.co.vividnext.sodalive.member.QMember.member | ||||
| import org.springframework.beans.factory.annotation.Value | ||||
| import org.springframework.data.jpa.repository.JpaRepository | ||||
| @@ -57,6 +59,7 @@ interface LiveRoomQueryRepository { | ||||
|     fun getActiveRoomIdList(memberId: Long): Int | ||||
|     fun getTotalHeartCount(roomId: Long): Int? | ||||
|     fun getLiveRoomCreatorId(roomId: Long): Long? | ||||
|     fun getHeartList(roomId: Long): List<GetLiveRoomHeartListItem> | ||||
| } | ||||
|  | ||||
| class LiveRoomQueryRepositoryImpl( | ||||
| @@ -346,4 +349,29 @@ class LiveRoomQueryRepositoryImpl( | ||||
|             ) | ||||
|             .fetchFirst() | ||||
|     } | ||||
|  | ||||
|     override fun getHeartList(roomId: Long): List<GetLiveRoomHeartListItem> { | ||||
|         val where = liveRoom.id.eq(roomId) | ||||
|             .and(useCan.canUsage.eq(CanUsage.HEART)) | ||||
|             .and(useCan.isRefund.isFalse) | ||||
|  | ||||
|         return queryFactory | ||||
|             .select( | ||||
|                 QGetLiveRoomHeartListItem( | ||||
|                     member.profileImage | ||||
|                         .coalesce("profile/default-profile.png") | ||||
|                         .prepend("/") | ||||
|                         .prepend(cloudFrontHost), | ||||
|                     member.nickname, | ||||
|                     useCan.can.add(useCan.rewardCan) | ||||
|                 ) | ||||
|             ) | ||||
|             .from(useCan) | ||||
|             .innerJoin(useCan.room, liveRoom) | ||||
|             .innerJoin(useCan.member, member) | ||||
|             .groupBy(useCan.member.id) | ||||
|             .where(where) | ||||
|             .orderBy(useCan.can.add(useCan.rewardCan).sum().desc()) | ||||
|             .fetch() | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -39,6 +39,7 @@ import kr.co.vividnext.sodalive.live.room.info.LiveRoomInfo | ||||
| import kr.co.vividnext.sodalive.live.room.info.LiveRoomInfoRedisRepository | ||||
| import kr.co.vividnext.sodalive.live.room.info.LiveRoomMember | ||||
| import kr.co.vividnext.sodalive.live.room.kickout.LiveRoomKickOutService | ||||
| import kr.co.vividnext.sodalive.live.room.like.GetLiveRoomHeartListResponse | ||||
| import kr.co.vividnext.sodalive.live.room.like.GetLiveRoomHeartTotalResponse | ||||
| import kr.co.vividnext.sodalive.live.room.like.LiveRoomLikeHeartRequest | ||||
| import kr.co.vividnext.sodalive.live.room.menu.CreateLiveMenuRequest | ||||
| @@ -1269,4 +1270,14 @@ class LiveRoomService( | ||||
|     fun getTotalHeartCount(roomId: Long): GetLiveRoomHeartTotalResponse { | ||||
|         return GetLiveRoomHeartTotalResponse(totalHeartCount = repository.getTotalHeartCount(roomId = roomId) ?: 0) | ||||
|     } | ||||
|  | ||||
|     fun getHeartList(roomId: Long): GetLiveRoomHeartListResponse { | ||||
|         val heartList = repository.getHeartList(roomId = roomId) | ||||
|  | ||||
|         return GetLiveRoomHeartListResponse( | ||||
|             heartList = heartList, | ||||
|             totalCount = heartList.size, | ||||
|             totalHeart = heartList.sumOf { it.heart } | ||||
|         ) | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user