차단유저 필터링 로직 추가
This commit is contained in:
		| @@ -44,6 +44,7 @@ class LiveRecommendRepository( | ||||
|  | ||||
|     fun getOnAirRecommendChannelList( | ||||
|         memberId: Long, | ||||
|         isBlocked: (Long) -> Boolean, | ||||
|         isAdult: Boolean | ||||
|     ): List<GetRecommendChannelResponse> { | ||||
|         var where = member.role.eq(MemberRole.CREATOR) | ||||
| @@ -75,12 +76,16 @@ class LiveRecommendRepository( | ||||
|             .orderBy(Expressions.numberTemplate(Double::class.java, "function('rand')").asc()) | ||||
|             .limit(20) | ||||
|             .fetch() | ||||
|             .asSequence() | ||||
|             .filter { !isBlocked(it.creatorId) } | ||||
|             .toList() | ||||
|     } | ||||
|  | ||||
|     fun getRecommendChannelList( | ||||
|         memberId: Long, | ||||
|         withOutCreatorList: List<Long>, | ||||
|         limit: Long | ||||
|         limit: Long, | ||||
|         isBlocked: (Long) -> Boolean | ||||
|     ): List<GetRecommendChannelResponse> { | ||||
|         val where = member.role.eq(MemberRole.CREATOR) | ||||
|             .and(member.isActive.isTrue) | ||||
|   | ||||
| @@ -1,10 +1,14 @@ | ||||
| package kr.co.vividnext.sodalive.live.recommend | ||||
|  | ||||
| import kr.co.vividnext.sodalive.member.Member | ||||
| import kr.co.vividnext.sodalive.member.block.BlockMemberRepository | ||||
| import org.springframework.stereotype.Service | ||||
|  | ||||
| @Service | ||||
| class LiveRecommendService(private val repository: LiveRecommendRepository) { | ||||
| class LiveRecommendService( | ||||
|     private val repository: LiveRecommendRepository, | ||||
|     private val blockMemberRepository: BlockMemberRepository | ||||
| ) { | ||||
|  | ||||
|     fun getRecommendLive(member: Member): List<GetRecommendLiveResponse> { | ||||
|         return repository.getRecommendLive( | ||||
| @@ -14,7 +18,11 @@ class LiveRecommendService(private val repository: LiveRecommendRepository) { | ||||
|     } | ||||
|  | ||||
|     fun getRecommendChannelList(member: Member): List<GetRecommendChannelResponse> { | ||||
|         val onAirChannelList = repository.getOnAirRecommendChannelList(member.id!!, isAdult = member.auth != null) | ||||
|         val onAirChannelList = repository.getOnAirRecommendChannelList( | ||||
|             member.id!!, | ||||
|             isBlocked = { blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it) }, | ||||
|             isAdult = member.auth != null | ||||
|         ) | ||||
|  | ||||
|         if (onAirChannelList.size >= 20) { | ||||
|             return onAirChannelList | ||||
| @@ -27,7 +35,8 @@ class LiveRecommendService(private val repository: LiveRecommendRepository) { | ||||
|         val notOnAirCreatorList = repository.getRecommendChannelList( | ||||
|             member.id!!, | ||||
|             withOutCreatorList = onAirCreatorIdList, | ||||
|             limit = (20 - onAirChannelList.size).toLong() | ||||
|             limit = (20 - onAirChannelList.size).toLong(), | ||||
|             isBlocked = { blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it) } | ||||
|         ) | ||||
|  | ||||
|         return onAirChannelList + notOnAirCreatorList | ||||
|   | ||||
| @@ -115,9 +115,13 @@ class LiveRoomService( | ||||
|                 isAdult = member.auth != null | ||||
|             ) | ||||
|             .asSequence() | ||||
|             .filter { !blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it.member!!.id!!) } | ||||
|             .map { | ||||
|                 val roomInfo = roomInfoRepository.findByIdOrNull(it.id!!) | ||||
|  | ||||
|                 val reservations = it.reservations | ||||
|                     .filter { reservation -> reservation.member!!.id!! == member.id!! && reservation.isActive } | ||||
|  | ||||
|                 val beginDateTime = it.beginDateTime | ||||
|                     .atZone(ZoneId.of("UTC")) | ||||
|                     .withZoneSameInstant(ZoneId.of(timezone)) | ||||
| @@ -138,13 +142,17 @@ class LiveRoomService( | ||||
|                     channelName = it.channelName, | ||||
|                     managerNickname = it.member!!.nickname, | ||||
|                     managerId = it.member!!.id!!, | ||||
|                     tags = listOf(), | ||||
|                     tags = it.tags | ||||
|                         .asSequence() | ||||
|                         .filter { tag -> tag.tag.isActive } | ||||
|                         .map { tag -> tag.tag.tag } | ||||
|                         .toList(), | ||||
|                     coverImageUrl = if (it.coverImage!!.startsWith("https://")) { | ||||
|                         it.coverImage!! | ||||
|                     } else { | ||||
|                         "$cloudFrontHost/${it.coverImage!!}" | ||||
|                     }, | ||||
|                     isReservation = false, | ||||
|                     isReservation = reservations.isNotEmpty(), | ||||
|                     isPrivateRoom = it.type == LiveRoomType.PRIVATE | ||||
|                 ) | ||||
|             } | ||||
| @@ -742,7 +750,7 @@ class LiveRoomService( | ||||
|             isSpeaker = isSpeaker, | ||||
|             isManager = isManager, | ||||
|             isFollowing = isFollowing, | ||||
|             isBlock = false | ||||
|             isBlock = blockMemberRepository.isBlocked(blockedMemberId = userResponse.id, memberId = memberResponse.id) | ||||
|         ) | ||||
|     } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user