test #223
| @@ -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.SodaException | ||||
| import kr.co.vividnext.sodalive.content.ContentType | ||||
| import kr.co.vividnext.sodalive.content.SortType | ||||
| import kr.co.vividnext.sodalive.member.Member | ||||
| import org.springframework.data.domain.Pageable | ||||
| @@ -18,12 +19,23 @@ class AudioContentCurationController(private val service: AudioContentCurationSe | ||||
|     @GetMapping("/{id}") | ||||
|     fun getCurationContent( | ||||
|         @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, | ||||
|         @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?, | ||||
|         pageable: Pageable | ||||
|     ) = run { | ||||
|         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 | ||||
|  | ||||
| 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.SortType | ||||
| import kr.co.vividnext.sodalive.content.main.GetAudioContentMainItem | ||||
| @@ -11,12 +12,18 @@ import org.springframework.stereotype.Repository | ||||
|  | ||||
| @Repository | ||||
| 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 | ||||
|             .and(audioContent.curation.id.eq(curationId)) | ||||
|  | ||||
|         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) | ||||
|                 ) | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return queryFactory | ||||
| @@ -31,6 +38,7 @@ class AudioContentCurationQueryRepository(private val queryFactory: JPAQueryFact | ||||
|         curationId: Long, | ||||
|         cloudfrontHost: String, | ||||
|         isAdult: Boolean = false, | ||||
|         contentType: ContentType, | ||||
|         sortType: SortType = SortType.NEWEST, | ||||
|         offset: Long = 0, | ||||
|         limit: Long = 10 | ||||
| @@ -49,6 +57,12 @@ class AudioContentCurationQueryRepository(private val queryFactory: JPAQueryFact | ||||
|  | ||||
|         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) | ||||
|                 ) | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return queryFactory | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| 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.member.Member | ||||
| import kr.co.vividnext.sodalive.member.block.BlockMemberRepository | ||||
| @@ -17,23 +18,28 @@ class AudioContentCurationService( | ||||
| ) { | ||||
|     fun getCurationContent( | ||||
|         curationId: Long, | ||||
|         isAdultContentVisible: Boolean, | ||||
|         contentType: ContentType, | ||||
|         sortType: SortType, | ||||
|         member: Member, | ||||
|         pageable: Pageable | ||||
|     ): 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( | ||||
|             curationId = curationId, | ||||
|             cloudfrontHost = cloudFrontHost, | ||||
|             isAdult = member.auth != null, | ||||
|             isAdult = member.auth != null && isAdultContentVisible, | ||||
|             contentType = contentType, | ||||
|             sortType = sortType, | ||||
|             offset = pageable.offset, | ||||
|             limit = pageable.pageSize.toLong() | ||||
|         ) | ||||
|             .asSequence() | ||||
|             .filter { !blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it.creatorId) } | ||||
|             .toList() | ||||
|  | ||||
|         return GetCurationContentResponse( | ||||
|             totalCount = totalCount, | ||||
|   | ||||
| @@ -116,7 +116,7 @@ class ContentSeriesQueryRepositoryImpl( | ||||
|         var where = series.isActive.isTrue | ||||
|  | ||||
|         if (!isAuth) { | ||||
|             where = where.and(audioContent.isAdult.isFalse) | ||||
|             where = where.and(series.isAdult.isFalse) | ||||
|         } else { | ||||
|             if (contentType != ContentType.ALL) { | ||||
|                 where = where.and( | ||||
|   | ||||
		Reference in New Issue
	
	Block a user