| @@ -64,6 +64,7 @@ interface AudioContentQueryRepository { | ||||
|         theme: String = "", | ||||
|         sortType: SortType = SortType.NEWEST, | ||||
|         isAdult: Boolean = false, | ||||
|         contentType: ContentType = ContentType.ALL, | ||||
|         offset: Long = 0, | ||||
|         limit: Long = 20 | ||||
|     ): List<GetAudioContentMainItem> | ||||
| @@ -79,11 +80,17 @@ interface AudioContentQueryRepository { | ||||
|         memberId: Long, | ||||
|         theme: String = "", | ||||
|         isAdult: Boolean = false, | ||||
|         contentType: ContentType = ContentType.ALL, | ||||
|         offset: Long = 0, | ||||
|         limit: Long = 20 | ||||
|     ): List<GetAudioContentMainItem> | ||||
|  | ||||
|     fun totalCountNewContentFor2Weeks(theme: String, memberId: Long, isAdult: Boolean): Int | ||||
|     fun totalCountNewContentFor2Weeks( | ||||
|         theme: String, | ||||
|         memberId: Long, | ||||
|         isAdult: Boolean, | ||||
|         contentType: ContentType = ContentType.ALL | ||||
|     ): Int | ||||
|  | ||||
|     fun getNewContentUploadCreatorList( | ||||
|         cloudfrontHost: String, | ||||
| @@ -95,7 +102,8 @@ interface AudioContentQueryRepository { | ||||
|     fun findAudioContentByCurationId( | ||||
|         curationId: Long, | ||||
|         cloudfrontHost: String, | ||||
|         isAdult: Boolean | ||||
|         isAdult: Boolean, | ||||
|         contentType: ContentType = ContentType.ALL | ||||
|     ): List<GetAudioContentMainItem> | ||||
|  | ||||
|     fun getAudioContentRanking( | ||||
| @@ -333,6 +341,7 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) | ||||
|         theme: String, | ||||
|         sortType: SortType, | ||||
|         isAdult: Boolean, | ||||
|         contentType: ContentType, | ||||
|         offset: Long, | ||||
|         limit: Long | ||||
|     ): List<GetAudioContentMainItem> { | ||||
| @@ -361,6 +370,13 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) | ||||
|  | ||||
|         if (!isAdult) { | ||||
|             where = where.and(audioContent.isAdult.isFalse) | ||||
|         } else { | ||||
|             if (contentType != ContentType.ALL) { | ||||
|                 where = where.and( | ||||
|                     audioContent.member.auth.gender.eq(if (contentType == ContentType.MALE) 0 else 1) | ||||
|                         .or(audioContent.isAdult.isFalse) | ||||
|                 ) | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         if (theme.isNotBlank()) { | ||||
| @@ -417,7 +433,12 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) | ||||
|             .size | ||||
|     } | ||||
|  | ||||
|     override fun totalCountNewContentFor2Weeks(theme: String, memberId: Long, isAdult: Boolean): Int { | ||||
|     override fun totalCountNewContentFor2Weeks( | ||||
|         theme: String, | ||||
|         memberId: Long, | ||||
|         isAdult: Boolean, | ||||
|         contentType: ContentType | ||||
|     ): Int { | ||||
|         var where = audioContent.isActive.isTrue | ||||
|             .and(audioContent.duration.isNotNull) | ||||
|             .and(audioContent.releaseDate.goe(LocalDateTime.now().minusWeeks(2))) | ||||
| @@ -429,6 +450,13 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) | ||||
|  | ||||
|         if (!isAdult) { | ||||
|             where = where.and(audioContent.isAdult.isFalse) | ||||
|         } else { | ||||
|             if (contentType != ContentType.ALL) { | ||||
|                 where = where.and( | ||||
|                     audioContent.member.auth.gender.eq(if (contentType == ContentType.MALE) 0 else 1) | ||||
|                         .or(audioContent.isAdult.isFalse) | ||||
|                 ) | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         if (theme.isNotBlank()) { | ||||
| @@ -450,6 +478,7 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) | ||||
|         memberId: Long, | ||||
|         theme: String, | ||||
|         isAdult: Boolean, | ||||
|         contentType: ContentType, | ||||
|         offset: Long, | ||||
|         limit: Long | ||||
|     ): List<GetAudioContentMainItem> { | ||||
| @@ -464,6 +493,13 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) | ||||
|  | ||||
|         if (!isAdult) { | ||||
|             where = where.and(audioContent.isAdult.isFalse) | ||||
|         } else { | ||||
|             if (contentType != ContentType.ALL) { | ||||
|                 where = where.and( | ||||
|                     audioContent.member.auth.gender.eq(if (contentType == ContentType.MALE) 0 else 1) | ||||
|                         .or(audioContent.isAdult.isFalse) | ||||
|                 ) | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         if (theme.isNotBlank()) { | ||||
| @@ -514,7 +550,6 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) | ||||
|             .orderBy(Expressions.numberTemplate(Double::class.java, "function('rand')").asc()) | ||||
|             .limit(20) | ||||
|             .fetch() | ||||
|             .asSequence() | ||||
|             .map { | ||||
|                 GetNewContentUploadCreator( | ||||
|                     it.id!!, | ||||
| @@ -526,7 +561,6 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) | ||||
|                     } | ||||
|                 ) | ||||
|             } | ||||
|             .toList() | ||||
|     } | ||||
|  | ||||
|     override fun getAudioContentMainBannerList(isAdult: Boolean): List<AudioContentBanner> { | ||||
| @@ -562,7 +596,8 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) | ||||
|     override fun findAudioContentByCurationId( | ||||
|         curationId: Long, | ||||
|         cloudfrontHost: String, | ||||
|         isAdult: Boolean | ||||
|         isAdult: Boolean, | ||||
|         contentType: ContentType | ||||
|     ): List<GetAudioContentMainItem> { | ||||
|         var where = audioContent.isActive.isTrue | ||||
|             .and(audioContent.member.isNotNull) | ||||
| @@ -572,6 +607,13 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) | ||||
|  | ||||
|         if (!isAdult) { | ||||
|             where = where.and(audioContent.isAdult.isFalse) | ||||
|         } else { | ||||
|             if (contentType != ContentType.ALL) { | ||||
|                 where = where.and( | ||||
|                     audioContent.member.auth.gender.eq(if (contentType == ContentType.MALE) 0 else 1) | ||||
|                         .or(audioContent.isAdult.isFalse) | ||||
|                 ) | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return queryFactory | ||||
|   | ||||
| @@ -0,0 +1,12 @@ | ||||
| package kr.co.vividnext.sodalive.content | ||||
|  | ||||
| enum class ContentType { | ||||
|     // 전체 | ||||
|     ALL, | ||||
|  | ||||
|     // 남성향 | ||||
|     MALE, | ||||
|  | ||||
|     // 여성향 | ||||
|     FEMALE | ||||
| } | ||||
| @@ -2,6 +2,7 @@ package kr.co.vividnext.sodalive.content.main | ||||
|  | ||||
| import kr.co.vividnext.sodalive.common.ApiResponse | ||||
| import kr.co.vividnext.sodalive.common.SodaException | ||||
| import kr.co.vividnext.sodalive.content.ContentType | ||||
| import kr.co.vividnext.sodalive.content.order.OrderService | ||||
| import kr.co.vividnext.sodalive.member.Member | ||||
| import org.springframework.data.domain.Pageable | ||||
| @@ -62,12 +63,22 @@ class AudioContentMainController( | ||||
|     @GetMapping("/new") | ||||
|     fun getNewContentByTheme( | ||||
|         @RequestParam("theme") theme: String, | ||||
|         @RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null, | ||||
|         @RequestParam("contentType", required = false) contentType: ContentType? = null, | ||||
|         @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?, | ||||
|         pageable: Pageable | ||||
|     ) = run { | ||||
|         if (member == null) throw SodaException("로그인 정보를 확인해주세요.") | ||||
|  | ||||
|         ApiResponse.ok(service.getNewContentByTheme(theme, member, pageable)) | ||||
|         ApiResponse.ok( | ||||
|             service.getNewContentByTheme( | ||||
|                 theme, | ||||
|                 isAdultContentVisible = isAdultContentVisible ?: true, | ||||
|                 contentType = contentType ?: ContentType.ALL, | ||||
|                 member, | ||||
|                 pageable | ||||
|             ) | ||||
|         ) | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/theme") | ||||
| @@ -82,16 +93,28 @@ class AudioContentMainController( | ||||
|     @GetMapping("/new/all") | ||||
|     fun getNewContentAllByTheme( | ||||
|         @RequestParam("theme") theme: String, | ||||
|         @RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null, | ||||
|         @RequestParam("contentType", required = false) contentType: ContentType? = null, | ||||
|         @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?, | ||||
|         pageable: Pageable | ||||
|     ) = run { | ||||
|         if (member == null) throw SodaException("로그인 정보를 확인해주세요.") | ||||
|  | ||||
|         ApiResponse.ok(service.getNewContentFor2WeeksByTheme(theme, member, pageable)) | ||||
|         ApiResponse.ok( | ||||
|             service.getNewContentFor2WeeksByTheme( | ||||
|                 theme = theme, | ||||
|                 isAdultContentVisible = isAdultContentVisible ?: true, | ||||
|                 contentType = contentType ?: ContentType.ALL, | ||||
|                 member = member, | ||||
|                 pageable = pageable | ||||
|             ) | ||||
|         ) | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/curation-list") | ||||
|     fun getCurationList( | ||||
|         @RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null, | ||||
|         @RequestParam("contentType", required = false) contentType: ContentType? = null, | ||||
|         @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?, | ||||
|         pageable: Pageable | ||||
|     ) = run { | ||||
| @@ -100,7 +123,8 @@ class AudioContentMainController( | ||||
|         ApiResponse.ok( | ||||
|             service.getAudioContentCurationListWithPaging( | ||||
|                 memberId = member.id!!, | ||||
|                 isAdult = member.auth != null, | ||||
|                 isAdult = member.auth != null && (isAdultContentVisible ?: true), | ||||
|                 contentType = contentType ?: ContentType.ALL, | ||||
|                 offset = pageable.offset, | ||||
|                 limit = pageable.pageSize.toLong() | ||||
|             ) | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| package kr.co.vividnext.sodalive.content.main | ||||
|  | ||||
| import kr.co.vividnext.sodalive.content.AudioContentRepository | ||||
| import kr.co.vividnext.sodalive.content.ContentType | ||||
| import kr.co.vividnext.sodalive.content.main.banner.AudioContentBannerType | ||||
| import kr.co.vividnext.sodalive.content.main.banner.GetAudioContentBannerResponse | ||||
| import kr.co.vividnext.sodalive.content.main.curation.GetAudioContentCurationResponse | ||||
| @@ -30,35 +31,49 @@ class AudioContentMainService( | ||||
|     } | ||||
|  | ||||
|     @Transactional(readOnly = true) | ||||
|     fun getNewContentByTheme(theme: String, member: Member, pageable: Pageable): List<GetAudioContentMainItem> { | ||||
|     fun getNewContentByTheme( | ||||
|         theme: String, | ||||
|         isAdultContentVisible: Boolean, | ||||
|         contentType: ContentType, | ||||
|         member: Member, | ||||
|         pageable: Pageable | ||||
|     ): List<GetAudioContentMainItem> { | ||||
|         return repository.findByTheme( | ||||
|             cloudfrontHost = imageHost, | ||||
|             memberId = member.id!!, | ||||
|             theme = theme, | ||||
|             isAdult = member.auth != null, | ||||
|             isAdult = member.auth != null && isAdultContentVisible, | ||||
|             contentType = contentType, | ||||
|             offset = pageable.offset, | ||||
|             limit = pageable.pageSize.toLong() | ||||
|         ) | ||||
|             .asSequence() | ||||
|             .filter { !blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it.creatorId) } | ||||
|             .toList() | ||||
|     } | ||||
|  | ||||
|     @Transactional(readOnly = true) | ||||
|     fun getNewContentFor2WeeksByTheme(theme: String, member: Member, pageable: Pageable): GetNewContentAllResponse { | ||||
|         val totalCount = | ||||
|             repository.totalCountNewContentFor2Weeks(theme, memberId = member.id!!, isAdult = member.auth != null) | ||||
|     fun getNewContentFor2WeeksByTheme( | ||||
|         theme: String, | ||||
|         isAdultContentVisible: Boolean, | ||||
|         contentType: ContentType, | ||||
|         member: Member, | ||||
|         pageable: Pageable | ||||
|     ): GetNewContentAllResponse { | ||||
|         val totalCount = repository.totalCountNewContentFor2Weeks( | ||||
|             theme, | ||||
|             memberId = member.id!!, | ||||
|             isAdult = member.auth != null && isAdultContentVisible, | ||||
|             contentType = contentType | ||||
|         ) | ||||
|         val items = repository.findByThemeFor2Weeks( | ||||
|             cloudfrontHost = imageHost, | ||||
|             memberId = member.id!!, | ||||
|             theme = theme, | ||||
|             isAdult = member.auth != null, | ||||
|             isAdult = member.auth != null && isAdultContentVisible, | ||||
|             contentType = contentType, | ||||
|             offset = pageable.offset, | ||||
|             limit = pageable.pageSize.toLong() | ||||
|         ) | ||||
|             .asSequence() | ||||
|             .filter { !blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it.creatorId) } | ||||
|             .toList() | ||||
|  | ||||
|         return GetNewContentAllResponse(totalCount, items) | ||||
|     } | ||||
| @@ -130,9 +145,13 @@ class AudioContentMainService( | ||||
|         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() | ||||
|     fun getAudioContentCurationListWithPaging( | ||||
|         memberId: Long, | ||||
|         isAdult: Boolean, | ||||
|         contentType: ContentType, | ||||
|         offset: Long, | ||||
|         limit: Long | ||||
|     ) = repository.getAudioContentCurationList(isAdult = isAdult, offset = offset, limit = limit) | ||||
|         .map { | ||||
|             GetAudioContentCurationResponse( | ||||
|                 curationId = it.id!!, | ||||
| @@ -141,15 +160,13 @@ class AudioContentMainService( | ||||
|                 contents = repository.findAudioContentByCurationId( | ||||
|                     curationId = it.id!!, | ||||
|                     cloudfrontHost = imageHost, | ||||
|                         isAdult = isAdult | ||||
|                     isAdult = isAdult, | ||||
|                     contentType = contentType | ||||
|                 ) | ||||
|                         .asSequence() | ||||
|                     .filter { content -> | ||||
|                         !blockMemberRepository.isBlocked(blockedMemberId = memberId, memberId = content.creatorId) | ||||
|                     } | ||||
|                         .toList() | ||||
|             ) | ||||
|         } | ||||
|         .filter { it.contents.isNotEmpty() } | ||||
|             .toList() | ||||
| } | ||||
|   | ||||
| @@ -33,12 +33,22 @@ class LiveRoomController( | ||||
|         @RequestParam timezone: String, | ||||
|         @RequestParam dateString: String? = null, | ||||
|         @RequestParam status: LiveRoomStatus, | ||||
|         @RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null, | ||||
|         @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?, | ||||
|         pageable: Pageable | ||||
|     ) = run { | ||||
|         if (member == null) throw SodaException("로그인 정보를 확인해주세요.") | ||||
|  | ||||
|         ApiResponse.ok(service.getRoomList(dateString, status, pageable, member, timezone)) | ||||
|         ApiResponse.ok( | ||||
|             service.getRoomList( | ||||
|                 dateString, | ||||
|                 status, | ||||
|                 isAdultContentVisible ?: true, | ||||
|                 pageable, | ||||
|                 member, | ||||
|                 timezone | ||||
|             ) | ||||
|         ) | ||||
|     } | ||||
|  | ||||
|     @PostMapping | ||||
|   | ||||
| @@ -113,6 +113,7 @@ class LiveRoomService( | ||||
|     fun getRoomList( | ||||
|         dateString: String?, | ||||
|         status: LiveRoomStatus, | ||||
|         isAdultContentVisible: Boolean, | ||||
|         pageable: Pageable, | ||||
|         member: Member, | ||||
|         timezone: String | ||||
| @@ -123,7 +124,7 @@ class LiveRoomService( | ||||
|                 timezone, | ||||
|                 memberId = member.id!!, | ||||
|                 isCreator = member.role == MemberRole.CREATOR, | ||||
|                 isAdult = member.auth != null | ||||
|                 isAdult = member.auth != null && isAdultContentVisible | ||||
|             ) | ||||
|         } else if (dateString != null) { | ||||
|             getLiveRoomListReservationWithDate( | ||||
| @@ -132,14 +133,14 @@ class LiveRoomService( | ||||
|                 timezone, | ||||
|                 memberId = member.id!!, | ||||
|                 isCreator = member.role == MemberRole.CREATOR, | ||||
|                 isAdult = member.auth != null | ||||
|                 isAdult = member.auth != null && isAdultContentVisible | ||||
|             ) | ||||
|         } else { | ||||
|             getLiveRoomListReservationWithoutDate( | ||||
|                 timezone, | ||||
|                 isCreator = member.role == MemberRole.CREATOR, | ||||
|                 memberId = member.id!!, | ||||
|                 isAdult = member.auth != null | ||||
|                 isAdult = member.auth != null && isAdultContentVisible | ||||
|             ) | ||||
|         } | ||||
|  | ||||
|   | ||||
| @@ -6,15 +6,17 @@ import kr.co.vividnext.sodalive.member.Member | ||||
| import org.springframework.security.access.prepost.PreAuthorize | ||||
| import org.springframework.security.core.annotation.AuthenticationPrincipal | ||||
| import org.springframework.web.bind.annotation.GetMapping | ||||
| import org.springframework.web.bind.annotation.PostMapping | ||||
| import org.springframework.web.bind.annotation.RequestBody | ||||
| import org.springframework.web.bind.annotation.RequestMapping | ||||
| import org.springframework.web.bind.annotation.RequestParam | ||||
| import org.springframework.web.bind.annotation.RestController | ||||
|  | ||||
| @RestController | ||||
| @PreAuthorize("hasRole('CREATOR')") | ||||
| @RequestMapping("/live/room/menu") | ||||
| class LiveRoomMenuController(private val service: LiveRoomMenuService) { | ||||
|     @GetMapping("/all") | ||||
|     @PreAuthorize("hasRole('CREATOR')") | ||||
|     fun getAllLiveMenu( | ||||
|         @RequestParam creatorId: Long, | ||||
|         @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member? | ||||
| @@ -23,4 +25,23 @@ class LiveRoomMenuController(private val service: LiveRoomMenuService) { | ||||
|  | ||||
|         ApiResponse.ok(service.getAllLiveMenu(creatorId = creatorId, memberId = member.id!!)) | ||||
|     } | ||||
|  | ||||
|     @PostMapping | ||||
|     fun createOrUpdateLiveMenu( | ||||
|         @RequestBody request: UpdateLiveMenuRequest, | ||||
|         @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member? | ||||
|     ) = run { | ||||
|         if (member == null) throw SodaException("로그인 정보를 확인해주세요.") | ||||
|  | ||||
|         ApiResponse.ok( | ||||
|             if (request.id > 0) { | ||||
|                 service.updateLiveMenu(memberId = member.id!!, request = request) | ||||
|             } else { | ||||
|                 service.createLiveMenu( | ||||
|                     memberId = member.id!!, | ||||
|                     request = CreateLiveMenuRequest(menu = request.menu, isActive = false) | ||||
|                 ) | ||||
|             } | ||||
|         ) | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user