라이브 방
- 엔티티 크리에이터 입장 가능 플래그 추가 - 라이브 방 생성시 크리에이터 입장 가능 여부 추가 - 라이브 방 조회시 크리에이터 입장 가능 여부 추가
This commit is contained in:
		| @@ -14,5 +14,6 @@ data class CreateLiveRoomRequest( | ||||
|     val password: String? = null, | ||||
|     val menuPanId: Long = 0, | ||||
|     val menuPan: String = "", | ||||
|     val isActiveMenuPan: Boolean = false | ||||
|     val isActiveMenuPan: Boolean = false, | ||||
|     val isAvailableJoinCreator: Boolean = true | ||||
| ) | ||||
|   | ||||
| @@ -28,6 +28,7 @@ data class LiveRoom( | ||||
|     var bgImage: String? = null, | ||||
|     var isAdult: Boolean, | ||||
|     val price: Int = 0, | ||||
|     val isAvailableJoinCreator: Boolean = true, | ||||
|     @Enumerated(value = EnumType.STRING) | ||||
|     val type: LiveRoomType = LiveRoomType.OPEN, | ||||
|     @Column(nullable = true) | ||||
|   | ||||
| @@ -20,16 +20,28 @@ import java.time.ZoneId | ||||
| interface LiveRoomRepository : JpaRepository<LiveRoom, Long>, LiveRoomQueryRepository | ||||
|  | ||||
| interface LiveRoomQueryRepository { | ||||
|     fun getLiveRoomListNow(offset: Long, limit: Long, timezone: String, isAdult: Boolean): List<LiveRoom> | ||||
|     fun getLiveRoomListNow( | ||||
|         offset: Long, | ||||
|         limit: Long, | ||||
|         timezone: String, | ||||
|         isCreator: Boolean, | ||||
|         isAdult: Boolean | ||||
|     ): List<LiveRoom> | ||||
|  | ||||
|     fun getLiveRoomListReservationWithDate( | ||||
|         date: LocalDateTime, | ||||
|         offset: Long, | ||||
|         limit: Long, | ||||
|         isCreator: Boolean, | ||||
|         isAdult: Boolean | ||||
|     ): List<LiveRoom> | ||||
|  | ||||
|     fun getLiveRoomListReservationWithoutDate(timezone: String, memberId: Long, isAdult: Boolean): List<LiveRoom> | ||||
|     fun getLiveRoomListReservationWithoutDate( | ||||
|         timezone: String, | ||||
|         memberId: Long, | ||||
|         isCreator: Boolean, | ||||
|         isAdult: Boolean | ||||
|     ): List<LiveRoom> | ||||
|  | ||||
|     fun getLiveRoom(id: Long): LiveRoom? | ||||
|     fun getLiveRoomAndAccountId(roomId: Long, memberId: Long): LiveRoom? | ||||
| @@ -40,7 +52,13 @@ interface LiveRoomQueryRepository { | ||||
| } | ||||
|  | ||||
| class LiveRoomQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : LiveRoomQueryRepository { | ||||
|     override fun getLiveRoomListNow(offset: Long, limit: Long, timezone: String, isAdult: Boolean): List<LiveRoom> { | ||||
|     override fun getLiveRoomListNow( | ||||
|         offset: Long, | ||||
|         limit: Long, | ||||
|         timezone: String, | ||||
|         isCreator: Boolean, | ||||
|         isAdult: Boolean | ||||
|     ): List<LiveRoom> { | ||||
|         var where = liveRoom.channelName.isNotNull | ||||
|             .and(liveRoom.channelName.isNotEmpty) | ||||
|             .and(liveRoom.isActive.isTrue) | ||||
| @@ -50,6 +68,10 @@ class LiveRoomQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : L | ||||
|             where = where.and(liveRoom.isAdult.isFalse) | ||||
|         } | ||||
|  | ||||
|         if (isCreator) { | ||||
|             where = where.and(liveRoom.isAvailableJoinCreator.isTrue) | ||||
|         } | ||||
|  | ||||
|         return queryFactory | ||||
|             .selectFrom(liveRoom) | ||||
|             .innerJoin(liveRoom.member, member) | ||||
| @@ -70,6 +92,7 @@ class LiveRoomQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : L | ||||
|         date: LocalDateTime, | ||||
|         offset: Long, | ||||
|         limit: Long, | ||||
|         isCreator: Boolean, | ||||
|         isAdult: Boolean | ||||
|     ): List<LiveRoom> { | ||||
|         var where = liveRoom.beginDateTime.goe(date) | ||||
| @@ -85,6 +108,10 @@ class LiveRoomQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : L | ||||
|             where = where.and(liveRoom.isAdult.isFalse) | ||||
|         } | ||||
|  | ||||
|         if (isCreator) { | ||||
|             where = where.and(liveRoom.isAvailableJoinCreator.isTrue) | ||||
|         } | ||||
|  | ||||
|         return queryFactory | ||||
|             .selectFrom(liveRoom) | ||||
|             .innerJoin(liveRoom.member, member) | ||||
| @@ -98,6 +125,7 @@ class LiveRoomQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : L | ||||
|     override fun getLiveRoomListReservationWithoutDate( | ||||
|         timezone: String, | ||||
|         memberId: Long, | ||||
|         isCreator: Boolean, | ||||
|         isAdult: Boolean | ||||
|     ): List<LiveRoom> { | ||||
|         var where = liveRoom.beginDateTime.gt( | ||||
| @@ -117,6 +145,10 @@ class LiveRoomQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : L | ||||
|             where = where.and(liveRoom.isAdult.isFalse) | ||||
|         } | ||||
|  | ||||
|         if (isCreator) { | ||||
|             where = where.and(liveRoom.isAvailableJoinCreator.isTrue) | ||||
|         } | ||||
|  | ||||
|         return queryFactory | ||||
|             .selectFrom(liveRoom) | ||||
|             .innerJoin(liveRoom.member, member) | ||||
|   | ||||
| @@ -118,17 +118,24 @@ class LiveRoomService( | ||||
|         timezone: String | ||||
|     ): List<GetRoomListResponse> { | ||||
|         val roomList = if (status == LiveRoomStatus.NOW) { | ||||
|             getLiveRoomListNow(pageable, timezone, isAdult = member.auth != null) | ||||
|             getLiveRoomListNow( | ||||
|                 pageable, | ||||
|                 timezone, | ||||
|                 isCreator = member.role == MemberRole.CREATOR, | ||||
|                 isAdult = member.auth != null | ||||
|             ) | ||||
|         } else if (dateString != null) { | ||||
|             getLiveRoomListReservationWithDate( | ||||
|                 dateString, | ||||
|                 pageable, | ||||
|                 timezone, | ||||
|                 isCreator = member.role == MemberRole.CREATOR, | ||||
|                 isAdult = member.auth != null | ||||
|             ) | ||||
|         } else { | ||||
|             getLiveRoomListReservationWithoutDate( | ||||
|                 timezone, | ||||
|                 isCreator = member.role == MemberRole.CREATOR, | ||||
|                 memberId = member.id!!, | ||||
|                 isAdult = member.auth != null | ||||
|             ) | ||||
| @@ -186,11 +193,17 @@ class LiveRoomService( | ||||
|             } | ||||
|     } | ||||
|  | ||||
|     private fun getLiveRoomListNow(pageable: Pageable, timezone: String, isAdult: Boolean): List<LiveRoom> { | ||||
|     private fun getLiveRoomListNow( | ||||
|         pageable: Pageable, | ||||
|         timezone: String, | ||||
|         isCreator: Boolean, | ||||
|         isAdult: Boolean | ||||
|     ): List<LiveRoom> { | ||||
|         return repository.getLiveRoomListNow( | ||||
|             offset = pageable.offset, | ||||
|             limit = pageable.pageSize.toLong(), | ||||
|             timezone = timezone, | ||||
|             isCreator = isCreator, | ||||
|             isAdult = isAdult | ||||
|         ) | ||||
|     } | ||||
| @@ -199,6 +212,7 @@ class LiveRoomService( | ||||
|         dateString: String, | ||||
|         pageable: Pageable, | ||||
|         timezone: String, | ||||
|         isCreator: Boolean, | ||||
|         isAdult: Boolean | ||||
|     ): List<LiveRoom> { | ||||
|         val dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd") | ||||
| @@ -211,6 +225,7 @@ class LiveRoomService( | ||||
|             date = date, | ||||
|             offset = pageable.offset, | ||||
|             limit = pageable.pageSize.toLong(), | ||||
|             isCreator = isCreator, | ||||
|             isAdult = isAdult | ||||
|         ) | ||||
|     } | ||||
| @@ -218,9 +233,10 @@ class LiveRoomService( | ||||
|     private fun getLiveRoomListReservationWithoutDate( | ||||
|         timezone: String, | ||||
|         memberId: Long, | ||||
|         isCreator: Boolean, | ||||
|         isAdult: Boolean | ||||
|     ): List<LiveRoom> { | ||||
|         return repository.getLiveRoomListReservationWithoutDate(timezone, memberId, isAdult) | ||||
|         return repository.getLiveRoomListReservationWithoutDate(timezone, memberId, isCreator, isAdult) | ||||
|     } | ||||
|  | ||||
|     @Transactional | ||||
| @@ -277,7 +293,8 @@ class LiveRoomService( | ||||
|                 request.price | ||||
|             }, | ||||
|             type = request.type, | ||||
|             password = request.password | ||||
|             password = request.password, | ||||
|             isAvailableJoinCreator = request.isAvailableJoinCreator | ||||
|         ) | ||||
|         room.member = member | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user