Merge pull request '라이브 방 - 크리에이터 입장 가능 설정 추가' (#179) from test into main
Reviewed-on: #179
This commit is contained in:
		| @@ -351,6 +351,10 @@ class ExplorerQueryRepository( | ||||
|             where = where.and(liveRoom.isAdult.isFalse) | ||||
|         } | ||||
|  | ||||
|         if (userMember.role == MemberRole.CREATOR) { | ||||
|             where = where.and(liveRoom.isAvailableJoinCreator.isTrue) | ||||
|         } | ||||
|  | ||||
|         val result = mutableListOf<LiveRoom>() | ||||
|  | ||||
|         if (offset == 0L) { | ||||
|   | ||||
| @@ -26,7 +26,8 @@ class FcmEvent( | ||||
|     val messageId: Long? = null, | ||||
|     val creatorId: Long? = null, | ||||
|     val commentParentId: Long? = null, | ||||
|     val myMemberId: Long? = null | ||||
|     val myMemberId: Long? = null, | ||||
|     val isAvailableJoinCreator: Boolean? = null | ||||
| ) | ||||
|  | ||||
| @Component | ||||
| @@ -99,6 +100,7 @@ class FcmSendListener( | ||||
|                     val pushTokens = memberRepository.getCreateLiveRoomNotificationRecipientPushTokens( | ||||
|                         creatorId = fcmEvent.creatorId!!, | ||||
|                         isAuth = fcmEvent.isAuth ?: false, | ||||
|                         isAvailableJoinCreator = fcmEvent.isAvailableJoinCreator ?: false, | ||||
|                         container = fcmEvent.container | ||||
|                     ) | ||||
|  | ||||
| @@ -120,6 +122,7 @@ class FcmSendListener( | ||||
|                         creatorId = fcmEvent.creatorId!!, | ||||
|                         roomId = fcmEvent.roomId!!, | ||||
|                         isAuth = fcmEvent.isAuth ?: false, | ||||
|                         isAvailableJoinCreator = fcmEvent.isAvailableJoinCreator ?: false, | ||||
|                         container = fcmEvent.container | ||||
|                     ) | ||||
|  | ||||
|   | ||||
| @@ -53,6 +53,7 @@ class LiveRecommendRepository( | ||||
|     fun getOnAirRecommendChannelList( | ||||
|         memberId: Long, | ||||
|         isBlocked: (Long) -> Boolean, | ||||
|         isCreator: Boolean, | ||||
|         isAdult: Boolean | ||||
|     ): List<GetRecommendChannelResponse> { | ||||
|         var where = member.role.eq(MemberRole.CREATOR) | ||||
| @@ -62,6 +63,10 @@ class LiveRecommendRepository( | ||||
|             where = where.and(liveRoom.isAdult.isFalse) | ||||
|         } | ||||
|  | ||||
|         if (isCreator) { | ||||
|             where = where.and(liveRoom.isAvailableJoinCreator.isTrue) | ||||
|         } | ||||
|  | ||||
|         return queryFactory | ||||
|             .select( | ||||
|                 Projections.constructor( | ||||
| @@ -113,14 +118,13 @@ class LiveRecommendRepository( | ||||
|             .orderBy(Expressions.numberTemplate(Double::class.java, "function('rand')").asc()) | ||||
|             .limit(limit) | ||||
|             .fetch() | ||||
|             .asSequence() | ||||
|             .filter { !isBlocked(it.creatorId) } | ||||
|             .toList() | ||||
|     } | ||||
|  | ||||
|     fun getOnAirFollowingChannelList( | ||||
|         memberId: Long, | ||||
|         isBlocked: (Long) -> Boolean, | ||||
|         isCreator: Boolean, | ||||
|         isAdult: Boolean | ||||
|     ): List<GetRecommendChannelResponse> { | ||||
|         var where = member.role.eq(MemberRole.CREATOR) | ||||
| @@ -130,6 +134,10 @@ class LiveRecommendRepository( | ||||
|             where = where.and(liveRoom.isAdult.isFalse) | ||||
|         } | ||||
|  | ||||
|         if (isCreator) { | ||||
|             where = where.and(liveRoom.isAvailableJoinCreator.isTrue) | ||||
|         } | ||||
|  | ||||
|         return queryFactory | ||||
|             .select( | ||||
|                 Projections.constructor( | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| package kr.co.vividnext.sodalive.live.recommend | ||||
|  | ||||
| import kr.co.vividnext.sodalive.member.Member | ||||
| import kr.co.vividnext.sodalive.member.MemberRole | ||||
| import kr.co.vividnext.sodalive.member.block.BlockMemberRepository | ||||
| import org.springframework.data.domain.Pageable | ||||
| import org.springframework.stereotype.Service | ||||
| @@ -23,6 +24,7 @@ class LiveRecommendService( | ||||
|         val onAirChannelList = repository.getOnAirRecommendChannelList( | ||||
|             member.id!!, | ||||
|             isBlocked = { blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it) }, | ||||
|             isCreator = member.role == MemberRole.CREATOR, | ||||
|             isAdult = member.auth != null | ||||
|         ) | ||||
|  | ||||
| @@ -30,9 +32,7 @@ class LiveRecommendService( | ||||
|             return onAirChannelList | ||||
|         } | ||||
|  | ||||
|         val onAirCreatorIdList = onAirChannelList.asSequence() | ||||
|             .map { it.creatorId } | ||||
|             .toList() | ||||
|         val onAirCreatorIdList = onAirChannelList.map { it.creatorId } | ||||
|  | ||||
|         val notOnAirCreatorList = repository.getRecommendChannelList( | ||||
|             member.id!!, | ||||
| @@ -48,6 +48,7 @@ class LiveRecommendService( | ||||
|         val onAirFollowingChannelList = repository.getOnAirFollowingChannelList( | ||||
|             memberId = member.id!!, | ||||
|             isBlocked = { blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it) }, | ||||
|             isCreator = member.role == MemberRole.CREATOR, | ||||
|             isAdult = member.auth != null | ||||
|         ) | ||||
|  | ||||
| @@ -55,9 +56,7 @@ class LiveRecommendService( | ||||
|             return onAirFollowingChannelList | ||||
|         } | ||||
|  | ||||
|         val onAirCreatorIdList = onAirFollowingChannelList.asSequence() | ||||
|             .map { it.creatorId } | ||||
|             .toList() | ||||
|         val onAirCreatorIdList = onAirFollowingChannelList.map { it.creatorId } | ||||
|  | ||||
|         val notOnAirFollowingChannelList = repository.getFollowingChannelList( | ||||
|             memberId = member.id!!, | ||||
|   | ||||
| @@ -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,30 @@ 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, | ||||
|         memberId: Long, | ||||
|         isCreator: Boolean, | ||||
|         isAdult: Boolean | ||||
|     ): List<LiveRoom> | ||||
|  | ||||
|     fun getLiveRoomListReservationWithDate( | ||||
|         date: LocalDateTime, | ||||
|         offset: Long, | ||||
|         limit: Long, | ||||
|         memberId: 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 +54,14 @@ 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, | ||||
|         memberId: Long, | ||||
|         isCreator: Boolean, | ||||
|         isAdult: Boolean | ||||
|     ): List<LiveRoom> { | ||||
|         var where = liveRoom.channelName.isNotNull | ||||
|             .and(liveRoom.channelName.isNotEmpty) | ||||
|             .and(liveRoom.isActive.isTrue) | ||||
| @@ -50,6 +71,13 @@ class LiveRoomQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : L | ||||
|             where = where.and(liveRoom.isAdult.isFalse) | ||||
|         } | ||||
|  | ||||
|         if (isCreator) { | ||||
|             where = where.and( | ||||
|                 liveRoom.isAvailableJoinCreator.isTrue | ||||
|                     .or(liveRoom.member.id.eq(memberId)) | ||||
|             ) | ||||
|         } | ||||
|  | ||||
|         return queryFactory | ||||
|             .selectFrom(liveRoom) | ||||
|             .innerJoin(liveRoom.member, member) | ||||
| @@ -70,6 +98,8 @@ class LiveRoomQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : L | ||||
|         date: LocalDateTime, | ||||
|         offset: Long, | ||||
|         limit: Long, | ||||
|         memberId: Long, | ||||
|         isCreator: Boolean, | ||||
|         isAdult: Boolean | ||||
|     ): List<LiveRoom> { | ||||
|         var where = liveRoom.beginDateTime.goe(date) | ||||
| @@ -85,6 +115,13 @@ class LiveRoomQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : L | ||||
|             where = where.and(liveRoom.isAdult.isFalse) | ||||
|         } | ||||
|  | ||||
|         if (isCreator) { | ||||
|             where = where.and( | ||||
|                 liveRoom.isAvailableJoinCreator.isTrue | ||||
|                     .or(liveRoom.member.id.eq(memberId)) | ||||
|             ) | ||||
|         } | ||||
|  | ||||
|         return queryFactory | ||||
|             .selectFrom(liveRoom) | ||||
|             .innerJoin(liveRoom.member, member) | ||||
| @@ -98,6 +135,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 +155,13 @@ class LiveRoomQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : L | ||||
|             where = where.and(liveRoom.isAdult.isFalse) | ||||
|         } | ||||
|  | ||||
|         if (isCreator) { | ||||
|             where = where.and( | ||||
|                 liveRoom.isAvailableJoinCreator.isTrue | ||||
|                     .or(liveRoom.member.id.eq(memberId)) | ||||
|             ) | ||||
|         } | ||||
|  | ||||
|         return queryFactory | ||||
|             .selectFrom(liveRoom) | ||||
|             .innerJoin(liveRoom.member, member) | ||||
|   | ||||
| @@ -118,17 +118,26 @@ class LiveRoomService( | ||||
|         timezone: String | ||||
|     ): List<GetRoomListResponse> { | ||||
|         val roomList = if (status == LiveRoomStatus.NOW) { | ||||
|             getLiveRoomListNow(pageable, timezone, isAdult = member.auth != null) | ||||
|             getLiveRoomListNow( | ||||
|                 pageable, | ||||
|                 timezone, | ||||
|                 memberId = member.id!!, | ||||
|                 isCreator = member.role == MemberRole.CREATOR, | ||||
|                 isAdult = member.auth != null | ||||
|             ) | ||||
|         } else if (dateString != null) { | ||||
|             getLiveRoomListReservationWithDate( | ||||
|                 dateString, | ||||
|                 pageable, | ||||
|                 timezone, | ||||
|                 memberId = member.id!!, | ||||
|                 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 +195,19 @@ class LiveRoomService( | ||||
|             } | ||||
|     } | ||||
|  | ||||
|     private fun getLiveRoomListNow(pageable: Pageable, timezone: String, isAdult: Boolean): List<LiveRoom> { | ||||
|     private fun getLiveRoomListNow( | ||||
|         pageable: Pageable, | ||||
|         timezone: String, | ||||
|         memberId: Long, | ||||
|         isCreator: Boolean, | ||||
|         isAdult: Boolean | ||||
|     ): List<LiveRoom> { | ||||
|         return repository.getLiveRoomListNow( | ||||
|             offset = pageable.offset, | ||||
|             limit = pageable.pageSize.toLong(), | ||||
|             timezone = timezone, | ||||
|             memberId = memberId, | ||||
|             isCreator = isCreator, | ||||
|             isAdult = isAdult | ||||
|         ) | ||||
|     } | ||||
| @@ -199,6 +216,8 @@ class LiveRoomService( | ||||
|         dateString: String, | ||||
|         pageable: Pageable, | ||||
|         timezone: String, | ||||
|         memberId: Long, | ||||
|         isCreator: Boolean, | ||||
|         isAdult: Boolean | ||||
|     ): List<LiveRoom> { | ||||
|         val dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd") | ||||
| @@ -211,6 +230,8 @@ class LiveRoomService( | ||||
|             date = date, | ||||
|             offset = pageable.offset, | ||||
|             limit = pageable.pageSize.toLong(), | ||||
|             memberId = memberId, | ||||
|             isCreator = isCreator, | ||||
|             isAdult = isAdult | ||||
|         ) | ||||
|     } | ||||
| @@ -218,9 +239,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 +299,8 @@ class LiveRoomService( | ||||
|                 request.price | ||||
|             }, | ||||
|             type = request.type, | ||||
|             password = request.password | ||||
|             password = request.password, | ||||
|             isAvailableJoinCreator = request.isAvailableJoinCreator | ||||
|         ) | ||||
|         room.member = member | ||||
|  | ||||
| @@ -353,6 +376,7 @@ class LiveRoomService( | ||||
|                     "라이브를 예약했습니다. - ${createdRoom.title}" | ||||
|                 }, | ||||
|                 isAuth = createdRoom.isAdult, | ||||
|                 isAvailableJoinCreator = createdRoom.isAvailableJoinCreator, | ||||
|                 roomId = createdRoom.id, | ||||
|                 creatorId = createdRoom.member!!.id, | ||||
|                 container = "ios" | ||||
| @@ -369,6 +393,7 @@ class LiveRoomService( | ||||
|                     "라이브를 예약했습니다. - ${createdRoom.title}" | ||||
|                 }, | ||||
|                 isAuth = createdRoom.isAdult, | ||||
|                 isAvailableJoinCreator = createdRoom.isAvailableJoinCreator, | ||||
|                 roomId = createdRoom.id, | ||||
|                 creatorId = createdRoom.member!!.id, | ||||
|                 container = "aos" | ||||
| @@ -511,6 +536,7 @@ class LiveRoomService( | ||||
|                 title = room.member!!.nickname, | ||||
|                 message = "라이브를 시작했습니다 - ${room.title}", | ||||
|                 isAuth = room.isAdult, | ||||
|                 isAvailableJoinCreator = room.isAvailableJoinCreator, | ||||
|                 roomId = room.id, | ||||
|                 creatorId = room.member!!.id, | ||||
|                 container = "ios" | ||||
| @@ -523,6 +549,7 @@ class LiveRoomService( | ||||
|                 title = room.member!!.nickname, | ||||
|                 message = "라이브를 시작했습니다 - ${room.title}", | ||||
|                 isAuth = room.isAdult, | ||||
|                 isAvailableJoinCreator = room.isAvailableJoinCreator, | ||||
|                 roomId = room.id, | ||||
|                 creatorId = room.member!!.id, | ||||
|                 container = "aos" | ||||
|   | ||||
| @@ -29,6 +29,7 @@ interface MemberQueryRepository { | ||||
|     fun getCreateLiveRoomNotificationRecipientPushTokens( | ||||
|         creatorId: Long, | ||||
|         isAuth: Boolean, | ||||
|         isAvailableJoinCreator: Boolean, | ||||
|         container: String | ||||
|     ): List<List<String>> | ||||
|  | ||||
| @@ -36,6 +37,7 @@ interface MemberQueryRepository { | ||||
|         creatorId: Long, | ||||
|         roomId: Long, | ||||
|         isAuth: Boolean, | ||||
|         isAvailableJoinCreator: Boolean, | ||||
|         container: String | ||||
|     ): List<List<String>> | ||||
|  | ||||
| @@ -120,6 +122,7 @@ class MemberQueryRepositoryImpl( | ||||
|     override fun getCreateLiveRoomNotificationRecipientPushTokens( | ||||
|         creatorId: Long, | ||||
|         isAuth: Boolean, | ||||
|         isAvailableJoinCreator: Boolean, | ||||
|         container: String | ||||
|     ): List<List<String>> { | ||||
|         val member = QMember.member | ||||
| @@ -142,6 +145,10 @@ class MemberQueryRepositoryImpl( | ||||
|             where = where.and(auth.isNotNull) | ||||
|         } | ||||
|  | ||||
|         if (!isAvailableJoinCreator) { | ||||
|             where = where.and(creatorFollowing.member.role.ne(MemberRole.CREATOR)) | ||||
|         } | ||||
|  | ||||
|         return queryFactory | ||||
|             .select(creatorFollowing.member.pushToken) | ||||
|             .from(creatorFollowing) | ||||
| @@ -159,6 +166,7 @@ class MemberQueryRepositoryImpl( | ||||
|         creatorId: Long, | ||||
|         roomId: Long, | ||||
|         isAuth: Boolean, | ||||
|         isAvailableJoinCreator: Boolean, | ||||
|         container: String | ||||
|     ): List<List<String>> { | ||||
|         val member = QMember.member | ||||
| @@ -181,6 +189,10 @@ class MemberQueryRepositoryImpl( | ||||
|             where = where.and(auth.isNotNull) | ||||
|         } | ||||
|  | ||||
|         if (!isAvailableJoinCreator) { | ||||
|             where = where.and(creatorFollowing.member.role.ne(MemberRole.CREATOR)) | ||||
|         } | ||||
|  | ||||
|         val followingMemberPushToken = queryFactory | ||||
|             .select(creatorFollowing.member.pushToken) | ||||
|             .from(creatorFollowing) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user