라이브 방
- 하트 후원 합계 조회 API 추가
This commit is contained in:
		| @@ -273,4 +273,14 @@ class LiveRoomController( | ||||
|  | ||||
|         ApiResponse.ok(service.likeHeart(request, member)) | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/{id}/heart-total") | ||||
|     fun getTotalHeartCount( | ||||
|         @PathVariable("id") roomId: Long, | ||||
|         @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member? | ||||
|     ) = run { | ||||
|         if (member == null) throw SodaException("로그인 정보를 확인해주세요.") | ||||
|  | ||||
|         ApiResponse.ok(service.getTotalHeartCount(roomId)) | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -53,6 +53,7 @@ interface LiveRoomQueryRepository { | ||||
|     fun getDonationList(roomId: Long, isLiveCreator: Boolean): List<GetLiveRoomDonationItem> | ||||
|     fun getRoomActiveAndChannelNameIsNotNull(memberId: Long): List<LiveRoom> | ||||
|     fun getActiveRoomIdList(memberId: Long): Int | ||||
|     fun getTotalHeartCount(roomId: Long): Int? | ||||
| } | ||||
|  | ||||
| class LiveRoomQueryRepositoryImpl( | ||||
| @@ -297,4 +298,18 @@ class LiveRoomQueryRepositoryImpl( | ||||
|             .fetch() | ||||
|             .size | ||||
|     } | ||||
|  | ||||
|     override fun getTotalHeartCount(roomId: Long): Int? { | ||||
|         val where = liveRoom.id.eq(roomId) | ||||
|             .and(useCan.canUsage.eq(CanUsage.HEART)) | ||||
|             .and(useCan.isRefund.isFalse) | ||||
|  | ||||
|         return queryFactory | ||||
|             .select(useCanCalculate.can.sum()) | ||||
|             .from(useCanCalculate) | ||||
|             .innerJoin(useCanCalculate.useCan, useCan) | ||||
|             .innerJoin(useCan.room, liveRoom) | ||||
|             .where(where) | ||||
|             .fetchOne() | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -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.GetLiveRoomHeartTotalResponse | ||||
| import kr.co.vividnext.sodalive.live.room.like.LiveRoomLikeHeartRequest | ||||
| import kr.co.vividnext.sodalive.live.room.menu.CreateLiveMenuRequest | ||||
| import kr.co.vividnext.sodalive.live.room.menu.LiveRoomMenuService | ||||
| @@ -1243,4 +1244,8 @@ class LiveRoomService( | ||||
|             container = request.container | ||||
|         ) | ||||
|     } | ||||
|  | ||||
|     fun getTotalHeartCount(roomId: Long): GetLiveRoomHeartTotalResponse { | ||||
|         return GetLiveRoomHeartTotalResponse(totalHeartCount = repository.getTotalHeartCount(roomId = roomId) ?: 0) | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -0,0 +1,5 @@ | ||||
| package kr.co.vividnext.sodalive.live.room.like | ||||
|  | ||||
| data class GetLiveRoomHeartTotalResponse( | ||||
|     val totalHeartCount: Int | ||||
| ) | ||||
		Reference in New Issue
	
	Block a user