| @@ -94,6 +94,8 @@ interface AudioContentQueryRepository { | |||||||
|         limit: Long = 12, |         limit: Long = 12, | ||||||
|         sortType: String = "매출" |         sortType: String = "매출" | ||||||
|     ): List<GetAudioContentRankingItem> |     ): List<GetAudioContentRankingItem> | ||||||
|  |  | ||||||
|  |     fun getAudioContentCurationList(isAdult: Boolean, offset: Long, limit: Long): List<AudioContentCuration> | ||||||
| } | } | ||||||
|  |  | ||||||
| @Repository | @Repository | ||||||
| @@ -544,4 +546,20 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) | |||||||
|             .limit(limit) |             .limit(limit) | ||||||
|             .fetch() |             .fetch() | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     override fun getAudioContentCurationList(isAdult: Boolean, offset: Long, limit: Long): List<AudioContentCuration> { | ||||||
|  |         var where = audioContentCuration.isActive.isTrue | ||||||
|  |  | ||||||
|  |         if (!isAdult) { | ||||||
|  |             where = where.and(audioContentCuration.isAdult.isFalse) | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         return queryFactory | ||||||
|  |             .selectFrom(audioContentCuration) | ||||||
|  |             .where(where) | ||||||
|  |             .offset(offset) | ||||||
|  |             .limit(limit) | ||||||
|  |             .orderBy(audioContentCuration.orders.asc()) | ||||||
|  |             .fetch() | ||||||
|  |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -2,6 +2,7 @@ package kr.co.vividnext.sodalive.content.main | |||||||
|  |  | ||||||
| import kr.co.vividnext.sodalive.common.ApiResponse | import kr.co.vividnext.sodalive.common.ApiResponse | ||||||
| import kr.co.vividnext.sodalive.common.SodaException | import kr.co.vividnext.sodalive.common.SodaException | ||||||
|  | import kr.co.vividnext.sodalive.content.order.OrderService | ||||||
| import kr.co.vividnext.sodalive.member.Member | import kr.co.vividnext.sodalive.member.Member | ||||||
| import org.springframework.data.domain.Pageable | import org.springframework.data.domain.Pageable | ||||||
| import org.springframework.security.core.annotation.AuthenticationPrincipal | import org.springframework.security.core.annotation.AuthenticationPrincipal | ||||||
| @@ -14,6 +15,7 @@ import org.springframework.web.bind.annotation.RestController | |||||||
| @RequestMapping("/audio-content/main") | @RequestMapping("/audio-content/main") | ||||||
| class AudioContentMainController( | class AudioContentMainController( | ||||||
|     private val service: AudioContentMainService, |     private val service: AudioContentMainService, | ||||||
|  |     private val orderService: OrderService, | ||||||
|     private val manageService: AudioContentMainManageService |     private val manageService: AudioContentMainManageService | ||||||
| ) { | ) { | ||||||
|  |  | ||||||
| @@ -26,6 +28,48 @@ class AudioContentMainController( | |||||||
|         ApiResponse.ok(manageService.getMain(member)) |         ApiResponse.ok(manageService.getMain(member)) | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @GetMapping("/new-content-upload-creator") | ||||||
|  |     fun newContentUploadCreatorList( | ||||||
|  |         @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member? | ||||||
|  |     ) = run { | ||||||
|  |         if (member == null) throw SodaException("로그인 정보를 확인해주세요.") | ||||||
|  |  | ||||||
|  |         ApiResponse.ok( | ||||||
|  |             service.getNewContentUploadCreatorList( | ||||||
|  |                 memberId = member.id!!, | ||||||
|  |                 isAdult = member.auth != null | ||||||
|  |             ) | ||||||
|  |         ) | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @GetMapping("/banner-list") | ||||||
|  |     fun getMainBannerList( | ||||||
|  |         @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member? | ||||||
|  |     ) = run { | ||||||
|  |         if (member == null) throw SodaException("로그인 정보를 확인해주세요.") | ||||||
|  |  | ||||||
|  |         ApiResponse.ok( | ||||||
|  |             service.getAudioContentMainBannerList( | ||||||
|  |                 memberId = member.id!!, | ||||||
|  |                 isAdult = member.auth != null | ||||||
|  |             ) | ||||||
|  |         ) | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @GetMapping("/order-list") | ||||||
|  |     fun getMainOrderList( | ||||||
|  |         @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member? | ||||||
|  |     ) = run { | ||||||
|  |         if (member == null) throw SodaException("로그인 정보를 확인해주세요.") | ||||||
|  |  | ||||||
|  |         ApiResponse.ok( | ||||||
|  |             orderService.getAudioContentMainOrderList( | ||||||
|  |                 memberId = member.id!!, | ||||||
|  |                 limit = 20 | ||||||
|  |             ) | ||||||
|  |         ) | ||||||
|  |     } | ||||||
|  |  | ||||||
|     @GetMapping("/new") |     @GetMapping("/new") | ||||||
|     fun getNewContentByTheme( |     fun getNewContentByTheme( | ||||||
|         @RequestParam("theme") theme: String, |         @RequestParam("theme") theme: String, | ||||||
| @@ -56,4 +100,21 @@ class AudioContentMainController( | |||||||
|  |  | ||||||
|         ApiResponse.ok(service.getNewContentFor2WeeksByTheme(theme, member, pageable)) |         ApiResponse.ok(service.getNewContentFor2WeeksByTheme(theme, member, pageable)) | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @GetMapping("/curation-list") | ||||||
|  |     fun getCurationList( | ||||||
|  |         @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?, | ||||||
|  |         pageable: Pageable | ||||||
|  |     ) = run { | ||||||
|  |         if (member == null) throw SodaException("로그인 정보를 확인해주세요.") | ||||||
|  |  | ||||||
|  |         ApiResponse.ok( | ||||||
|  |             service.getAudioContentCurationListWithPaging( | ||||||
|  |                 memberId = member.id!!, | ||||||
|  |                 isAdult = member.auth != null, | ||||||
|  |                 offset = pageable.offset, | ||||||
|  |                 limit = pageable.pageSize.toLong() | ||||||
|  |             ) | ||||||
|  |         ) | ||||||
|  |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -29,6 +29,7 @@ class AudioContentMainService( | |||||||
|         return audioContentThemeRepository.getActiveThemeOfContent(isAdult = isAdult) |         return audioContentThemeRepository.getActiveThemeOfContent(isAdult = isAdult) | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Transactional(readOnly = true) | ||||||
|     fun getNewContentByTheme(theme: String, member: Member, pageable: Pageable): List<GetAudioContentMainItem> { |     fun getNewContentByTheme(theme: String, member: Member, pageable: Pageable): List<GetAudioContentMainItem> { | ||||||
|         return repository.findByTheme( |         return repository.findByTheme( | ||||||
|             cloudfrontHost = imageHost, |             cloudfrontHost = imageHost, | ||||||
| @@ -42,6 +43,7 @@ class AudioContentMainService( | |||||||
|             .toList() |             .toList() | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Transactional(readOnly = true) | ||||||
|     fun getNewContentFor2WeeksByTheme(theme: String, member: Member, pageable: Pageable): GetNewContentAllResponse { |     fun getNewContentFor2WeeksByTheme(theme: String, member: Member, pageable: Pageable): GetNewContentAllResponse { | ||||||
|         val totalCount = repository.totalCountNewContentFor2Weeks(theme, isAdult = member.auth != null) |         val totalCount = repository.totalCountNewContentFor2Weeks(theme, isAdult = member.auth != null) | ||||||
|         val items = repository.findByThemeFor2Weeks( |         val items = repository.findByThemeFor2Weeks( | ||||||
| @@ -141,4 +143,32 @@ class AudioContentMainService( | |||||||
|             } |             } | ||||||
|             .filter { it.contents.isNotEmpty() } |             .filter { it.contents.isNotEmpty() } | ||||||
|             .toList() |             .toList() | ||||||
|  |  | ||||||
|  |     @Transactional(readOnly = true) | ||||||
|  |     @Cacheable( | ||||||
|  |         cacheNames = ["default"], | ||||||
|  |         key = "'getAudioContentCurationListWithPaging:' + #memberId + ':' + #isAdult + ':' + #offset + ':' + #limit" | ||||||
|  |     ) | ||||||
|  |     fun getAudioContentCurationListWithPaging(memberId: Long, isAdult: Boolean, offset: Long, limit: Long) = | ||||||
|  |         repository.getAudioContentCurationList(isAdult = isAdult, offset = offset, limit = limit) | ||||||
|  |             .asSequence() | ||||||
|  |             .map { | ||||||
|  |                 GetAudioContentCurationResponse( | ||||||
|  |                     curationId = it.id!!, | ||||||
|  |                     title = it.title, | ||||||
|  |                     description = it.description, | ||||||
|  |                     contents = repository.findAudioContentByCurationId( | ||||||
|  |                         curationId = it.id!!, | ||||||
|  |                         cloudfrontHost = imageHost, | ||||||
|  |                         isAdult = isAdult | ||||||
|  |                     ) | ||||||
|  |                         .asSequence() | ||||||
|  |                         .filter { content -> | ||||||
|  |                             !blockMemberRepository.isBlocked(blockedMemberId = memberId, memberId = content.creatorId) | ||||||
|  |                         } | ||||||
|  |                         .toList() | ||||||
|  |                 ) | ||||||
|  |             } | ||||||
|  |             .filter { it.contents.isNotEmpty() } | ||||||
|  |             .toList() | ||||||
| } | } | ||||||
|   | |||||||
| @@ -41,7 +41,7 @@ interface LiveRoomQueryRepository { | |||||||
|     fun getRecentRoomInfo(memberId: Long, cloudFrontHost: String): GetRecentRoomInfoResponse? |     fun getRecentRoomInfo(memberId: Long, cloudFrontHost: String): GetRecentRoomInfoResponse? | ||||||
|     fun getDonationTotal(roomId: Long): Int? |     fun getDonationTotal(roomId: Long): Int? | ||||||
|     fun getDonationList(roomId: Long, cloudFrontHost: String): List<GetLiveRoomDonationItem> |     fun getDonationList(roomId: Long, cloudFrontHost: String): List<GetLiveRoomDonationItem> | ||||||
|     fun getRoomActiveAndChannelNameIsNotNull(): List<LiveRoom> |     fun getRoomActiveAndChannelNameIsNotNull(memberId: Long): List<LiveRoom> | ||||||
| } | } | ||||||
|  |  | ||||||
| class LiveRoomQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : LiveRoomQueryRepository { | class LiveRoomQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : LiveRoomQueryRepository { | ||||||
| @@ -191,12 +191,13 @@ class LiveRoomQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : L | |||||||
|             .fetch() |             .fetch() | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     override fun getRoomActiveAndChannelNameIsNotNull(): List<LiveRoom> { |     override fun getRoomActiveAndChannelNameIsNotNull(memberId: Long): List<LiveRoom> { | ||||||
|         return queryFactory |         return queryFactory | ||||||
|             .selectFrom(liveRoom) |             .selectFrom(liveRoom) | ||||||
|             .where( |             .where( | ||||||
|                 liveRoom.isActive.isTrue |                 liveRoom.isActive.isTrue | ||||||
|                     .and(liveRoom.channelName.isNotNull) |                     .and(liveRoom.channelName.isNotNull) | ||||||
|  |                     .and(liveRoom.member.id.eq(memberId)) | ||||||
|             ) |             ) | ||||||
|             .fetch() |             .fetch() | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -183,7 +183,7 @@ class LiveRoomService( | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (now == beginDateTime) { |         if (now == beginDateTime) { | ||||||
|             val activeRooms = repository.getRoomActiveAndChannelNameIsNotNull() |             val activeRooms = repository.getRoomActiveAndChannelNameIsNotNull(memberId = member.id!!) | ||||||
|             for (activeRoom in activeRooms) { |             for (activeRoom in activeRooms) { | ||||||
|                 activeRoom.isActive = false |                 activeRoom.isActive = false | ||||||
|             } |             } | ||||||
| @@ -410,7 +410,7 @@ class LiveRoomService( | |||||||
|             throw SodaException("$startAvailableDateTimeString 이후에 시작할 수 있습니다.") |             throw SodaException("$startAvailableDateTimeString 이후에 시작할 수 있습니다.") | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         val activeRooms = repository.getRoomActiveAndChannelNameIsNotNull() |         val activeRooms = repository.getRoomActiveAndChannelNameIsNotNull(memberId = member.id!!) | ||||||
|         for (activeRoom in activeRooms) { |         for (activeRoom in activeRooms) { | ||||||
|             activeRoom.isActive = false |             activeRoom.isActive = false | ||||||
|         } |         } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user