diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/explorer/ExplorerQueryRepository.kt b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/ExplorerQueryRepository.kt index 7c1abf6..330bd33 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/explorer/ExplorerQueryRepository.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/ExplorerQueryRepository.kt @@ -69,6 +69,7 @@ class ExplorerQueryRepository( useCanCalculate.status.eq(UseCanCalculateStatus.RECEIVED) .and( useCan.canUsage.eq(CanUsage.DONATION) + .or(useCan.canUsage.eq(CanUsage.SPIN_ROULETTE)) .or(useCan.canUsage.eq(CanUsage.LIVE)) ) .and(useCan.isRefund.isFalse) @@ -107,6 +108,7 @@ class ExplorerQueryRepository( .and(useCanCalculate.recipientCreatorId.eq(creatorId)) .and( useCan.canUsage.eq(CanUsage.DONATION) + .or(useCan.canUsage.eq(CanUsage.SPIN_ROULETTE)) .or(useCan.canUsage.eq(CanUsage.LIVE)) ) ) @@ -137,6 +139,7 @@ class ExplorerQueryRepository( .and(useCanCalculate.recipientCreatorId.eq(creatorId)) .and( useCan.canUsage.eq(CanUsage.DONATION) + .or(useCan.canUsage.eq(CanUsage.SPIN_ROULETTE)) .or(useCan.canUsage.eq(CanUsage.LIVE)) ) ) 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 4b4715f..b7de267 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 @@ -41,6 +41,7 @@ interface LiveRoomQueryRepository { fun getRecentRoomInfo(memberId: Long, cloudFrontHost: String): GetRecentRoomInfoResponse? fun getDonationTotal(roomId: Long): Int? fun getDonationList(roomId: Long, cloudFrontHost: String): List + fun getRoomActiveAndChannelNameIsNotNull(): List } class LiveRoomQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : LiveRoomQueryRepository { @@ -190,6 +191,16 @@ class LiveRoomQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : L .fetch() } + override fun getRoomActiveAndChannelNameIsNotNull(): List { + return queryFactory + .selectFrom(liveRoom) + .where( + liveRoom.isActive.isTrue + .and(liveRoom.channelName.isNotNull) + ) + .fetch() + } + private fun orderByFieldAccountId( memberId: Long, status: LiveRoomStatus, 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 be21081..46577ed 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 @@ -182,6 +182,13 @@ class LiveRoomService( now } + if (now == beginDateTime) { + val activeRooms = repository.getRoomActiveAndChannelNameIsNotNull() + for (activeRoom in activeRooms) { + activeRoom.isActive = false + } + } + if ( request.beginDateTimeString != null && beginDateTime < now.plusMinutes(30) @@ -403,6 +410,11 @@ class LiveRoomService( throw SodaException("$startAvailableDateTimeString 이후에 시작할 수 있습니다.") } + val activeRooms = repository.getRoomActiveAndChannelNameIsNotNull() + for (activeRoom in activeRooms) { + activeRoom.isActive = false + } + val dateTime = nowDateTime .atZone(ZoneId.of("UTC")) .withZoneSameInstant(ZoneId.of(request.timezone))