Merge pull request '예약 라이브 개수 제한' (#217) from test into main

Reviewed-on: #217
This commit is contained in:
klaus 2024-09-25 05:42:45 +00:00
commit 4c935c3bee
2 changed files with 18 additions and 0 deletions

View File

@ -52,6 +52,7 @@ interface LiveRoomQueryRepository {
fun getDonationTotal(roomId: Long, isLiveCreator: Boolean): Int?
fun getDonationList(roomId: Long, isLiveCreator: Boolean): List<GetLiveRoomDonationItem>
fun getRoomActiveAndChannelNameIsNotNull(memberId: Long): List<LiveRoom>
fun getActiveRoomIdList(memberId: Long): Int
}
class LiveRoomQueryRepositoryImpl(
@ -283,4 +284,17 @@ class LiveRoomQueryRepositoryImpl(
)
.fetch()
}
override fun getActiveRoomIdList(memberId: Long): Int {
return queryFactory
.select(liveRoom.id)
.from(liveRoom)
.where(
liveRoom.isActive.isTrue
.and(liveRoom.channelName.isNull)
.and(liveRoom.member.id.eq(memberId))
)
.fetch()
.size
}
}

View File

@ -247,6 +247,10 @@ class LiveRoomService(
@Transactional
fun createLiveRoom(coverImage: MultipartFile?, requestString: String, member: Member): CreateLiveRoomResponse {
if (repository.getActiveRoomIdList(memberId = member.id!!) >= 3) {
throw SodaException("예약 라이브는 최대 3개까지 가능합니다.")
}
val request = objectMapper.readValue(requestString, CreateLiveRoomRequest::class.java)
if (request.coverImageUrl == null && coverImage == null) {
throw SodaException("커버이미지를 선택해 주세요.")