| @@ -2,6 +2,7 @@ package kr.co.vividnext.sodalive.content.main.curation | |||||||
|  |  | ||||||
| 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.ContentType | ||||||
| import kr.co.vividnext.sodalive.content.SortType | import kr.co.vividnext.sodalive.content.SortType | ||||||
| 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 | ||||||
| @@ -18,12 +19,23 @@ class AudioContentCurationController(private val service: AudioContentCurationSe | |||||||
|     @GetMapping("/{id}") |     @GetMapping("/{id}") | ||||||
|     fun getCurationContent( |     fun getCurationContent( | ||||||
|         @PathVariable id: Long, |         @PathVariable id: Long, | ||||||
|  |         @RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null, | ||||||
|  |         @RequestParam("contentType", required = false) contentType: ContentType? = null, | ||||||
|         @RequestParam("sort-type", required = false) sortType: SortType? = SortType.NEWEST, |         @RequestParam("sort-type", required = false) sortType: SortType? = SortType.NEWEST, | ||||||
|         @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?, |         @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?, | ||||||
|         pageable: Pageable |         pageable: Pageable | ||||||
|     ) = run { |     ) = run { | ||||||
|         if (member == null) throw SodaException("로그인 정보를 확인해주세요.") |         if (member == null) throw SodaException("로그인 정보를 확인해주세요.") | ||||||
|  |  | ||||||
|         ApiResponse.ok(service.getCurationContent(id, sortType ?: SortType.NEWEST, member, pageable)) |         ApiResponse.ok( | ||||||
|  |             service.getCurationContent( | ||||||
|  |                 curationId = id, | ||||||
|  |                 isAdultContentVisible = isAdultContentVisible ?: true, | ||||||
|  |                 contentType = contentType ?: ContentType.ALL, | ||||||
|  |                 sortType = sortType ?: SortType.NEWEST, | ||||||
|  |                 member = member, | ||||||
|  |                 pageable = pageable | ||||||
|  |             ) | ||||||
|  |         ) | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,6 +1,7 @@ | |||||||
| package kr.co.vividnext.sodalive.content.main.curation | package kr.co.vividnext.sodalive.content.main.curation | ||||||
|  |  | ||||||
| import com.querydsl.jpa.impl.JPAQueryFactory | import com.querydsl.jpa.impl.JPAQueryFactory | ||||||
|  | import kr.co.vividnext.sodalive.content.ContentType | ||||||
| import kr.co.vividnext.sodalive.content.QAudioContent.audioContent | import kr.co.vividnext.sodalive.content.QAudioContent.audioContent | ||||||
| import kr.co.vividnext.sodalive.content.SortType | import kr.co.vividnext.sodalive.content.SortType | ||||||
| import kr.co.vividnext.sodalive.content.main.GetAudioContentMainItem | import kr.co.vividnext.sodalive.content.main.GetAudioContentMainItem | ||||||
| @@ -11,12 +12,18 @@ import org.springframework.stereotype.Repository | |||||||
|  |  | ||||||
| @Repository | @Repository | ||||||
| class AudioContentCurationQueryRepository(private val queryFactory: JPAQueryFactory) { | class AudioContentCurationQueryRepository(private val queryFactory: JPAQueryFactory) { | ||||||
|     fun findTotalCountByCurationId(curationId: Long, isAdult: Boolean = false): Int { |     fun findTotalCountByCurationId(curationId: Long, isAdult: Boolean, contentType: ContentType): Int { | ||||||
|         var where = audioContent.isActive.isTrue |         var where = audioContent.isActive.isTrue | ||||||
|             .and(audioContent.curation.id.eq(curationId)) |             .and(audioContent.curation.id.eq(curationId)) | ||||||
|  |  | ||||||
|         if (!isAdult) { |         if (!isAdult) { | ||||||
|             where = where.and(audioContent.isAdult.isFalse) |             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) | ||||||
|  |                 ) | ||||||
|  |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return queryFactory |         return queryFactory | ||||||
| @@ -31,6 +38,7 @@ class AudioContentCurationQueryRepository(private val queryFactory: JPAQueryFact | |||||||
|         curationId: Long, |         curationId: Long, | ||||||
|         cloudfrontHost: String, |         cloudfrontHost: String, | ||||||
|         isAdult: Boolean = false, |         isAdult: Boolean = false, | ||||||
|  |         contentType: ContentType, | ||||||
|         sortType: SortType = SortType.NEWEST, |         sortType: SortType = SortType.NEWEST, | ||||||
|         offset: Long = 0, |         offset: Long = 0, | ||||||
|         limit: Long = 10 |         limit: Long = 10 | ||||||
| @@ -49,6 +57,12 @@ class AudioContentCurationQueryRepository(private val queryFactory: JPAQueryFact | |||||||
|  |  | ||||||
|         if (!isAdult) { |         if (!isAdult) { | ||||||
|             where = where.and(audioContent.isAdult.isFalse) |             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) | ||||||
|  |                 ) | ||||||
|  |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return queryFactory |         return queryFactory | ||||||
|   | |||||||
| @@ -1,5 +1,6 @@ | |||||||
| package kr.co.vividnext.sodalive.content.main.curation | package kr.co.vividnext.sodalive.content.main.curation | ||||||
|  |  | ||||||
|  | import kr.co.vividnext.sodalive.content.ContentType | ||||||
| import kr.co.vividnext.sodalive.content.SortType | import kr.co.vividnext.sodalive.content.SortType | ||||||
| import kr.co.vividnext.sodalive.member.Member | import kr.co.vividnext.sodalive.member.Member | ||||||
| import kr.co.vividnext.sodalive.member.block.BlockMemberRepository | import kr.co.vividnext.sodalive.member.block.BlockMemberRepository | ||||||
| @@ -17,23 +18,28 @@ class AudioContentCurationService( | |||||||
| ) { | ) { | ||||||
|     fun getCurationContent( |     fun getCurationContent( | ||||||
|         curationId: Long, |         curationId: Long, | ||||||
|  |         isAdultContentVisible: Boolean, | ||||||
|  |         contentType: ContentType, | ||||||
|         sortType: SortType, |         sortType: SortType, | ||||||
|         member: Member, |         member: Member, | ||||||
|         pageable: Pageable |         pageable: Pageable | ||||||
|     ): GetCurationContentResponse { |     ): GetCurationContentResponse { | ||||||
|         val totalCount = repository.findTotalCountByCurationId(curationId, member.auth != null) |         val totalCount = repository.findTotalCountByCurationId( | ||||||
|  |             curationId = curationId, | ||||||
|  |             isAdult = member.auth != null && isAdultContentVisible, | ||||||
|  |             contentType = contentType | ||||||
|  |         ) | ||||||
|  |  | ||||||
|         val audioContentList = repository.findByCurationId( |         val audioContentList = repository.findByCurationId( | ||||||
|             curationId = curationId, |             curationId = curationId, | ||||||
|             cloudfrontHost = cloudFrontHost, |             cloudfrontHost = cloudFrontHost, | ||||||
|             isAdult = member.auth != null, |             isAdult = member.auth != null && isAdultContentVisible, | ||||||
|  |             contentType = contentType, | ||||||
|             sortType = sortType, |             sortType = sortType, | ||||||
|             offset = pageable.offset, |             offset = pageable.offset, | ||||||
|             limit = pageable.pageSize.toLong() |             limit = pageable.pageSize.toLong() | ||||||
|         ) |         ) | ||||||
|             .asSequence() |  | ||||||
|             .filter { !blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it.creatorId) } |             .filter { !blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it.creatorId) } | ||||||
|             .toList() |  | ||||||
|  |  | ||||||
|         return GetCurationContentResponse( |         return GetCurationContentResponse( | ||||||
|             totalCount = totalCount, |             totalCount = totalCount, | ||||||
|   | |||||||
| @@ -116,7 +116,7 @@ class ContentSeriesQueryRepositoryImpl( | |||||||
|         var where = series.isActive.isTrue |         var where = series.isActive.isTrue | ||||||
|  |  | ||||||
|         if (!isAuth) { |         if (!isAuth) { | ||||||
|             where = where.and(audioContent.isAdult.isFalse) |             where = where.and(series.isAdult.isFalse) | ||||||
|         } else { |         } else { | ||||||
|             if (contentType != ContentType.ALL) { |             if (contentType != ContentType.ALL) { | ||||||
|                 where = where.and( |                 where = where.and( | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user