| @@ -263,7 +263,7 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) | |||||||
|  |  | ||||||
|     override fun totalCountNewContentFor2Weeks(theme: String, isAdult: Boolean): Int { |     override fun totalCountNewContentFor2Weeks(theme: String, isAdult: Boolean): Int { | ||||||
|         var where = audioContent.isActive.isTrue |         var where = audioContent.isActive.isTrue | ||||||
|             .and(audioContent.createdAt.loe(LocalDateTime.now())) |             .and(audioContent.createdAt.goe(LocalDateTime.now().minusWeeks(2))) | ||||||
|  |  | ||||||
|         if (!isAdult) { |         if (!isAdult) { | ||||||
|             where = where.and(audioContent.isAdult.isFalse) |             where = where.and(audioContent.isAdult.isFalse) | ||||||
| @@ -291,7 +291,7 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) | |||||||
|         limit: Long |         limit: Long | ||||||
|     ): List<GetAudioContentMainItem> { |     ): List<GetAudioContentMainItem> { | ||||||
|         var where = audioContent.isActive.isTrue |         var where = audioContent.isActive.isTrue | ||||||
|             .and(audioContent.createdAt.loe(LocalDateTime.now())) |             .and(audioContent.createdAt.goe(LocalDateTime.now().minusWeeks(2))) | ||||||
|  |  | ||||||
|         if (!isAdult) { |         if (!isAdult) { | ||||||
|             where = where.and(audioContent.isAdult.isFalse) |             where = where.and(audioContent.isAdult.isFalse) | ||||||
|   | |||||||
| @@ -1,9 +1,12 @@ | |||||||
| 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.AudioContent |  | ||||||
| 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.QGetAudioContentMainItem | ||||||
|  | import kr.co.vividnext.sodalive.content.theme.QAudioContentTheme.audioContentTheme | ||||||
|  | import kr.co.vividnext.sodalive.member.QMember.member | ||||||
| import org.springframework.stereotype.Repository | import org.springframework.stereotype.Repository | ||||||
|  |  | ||||||
| @Repository | @Repository | ||||||
| @@ -26,11 +29,12 @@ class AudioContentCurationQueryRepository(private val queryFactory: JPAQueryFact | |||||||
|  |  | ||||||
|     fun findByCurationId( |     fun findByCurationId( | ||||||
|         curationId: Long, |         curationId: Long, | ||||||
|  |         cloudfrontHost: String, | ||||||
|         isAdult: Boolean = false, |         isAdult: Boolean = false, | ||||||
|         sortType: SortType = SortType.NEWEST, |         sortType: SortType = SortType.NEWEST, | ||||||
|         offset: Long = 0, |         offset: Long = 0, | ||||||
|         limit: Long = 10 |         limit: Long = 10 | ||||||
|     ): List<AudioContent> { |     ): List<GetAudioContentMainItem> { | ||||||
|         val orderBy = when (sortType) { |         val orderBy = when (sortType) { | ||||||
|             SortType.NEWEST -> audioContent.createdAt.desc() |             SortType.NEWEST -> audioContent.createdAt.desc() | ||||||
|             SortType.PRICE_HIGH -> audioContent.price.desc() |             SortType.PRICE_HIGH -> audioContent.price.desc() | ||||||
| @@ -48,7 +52,20 @@ class AudioContentCurationQueryRepository(private val queryFactory: JPAQueryFact | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         return queryFactory |         return queryFactory | ||||||
|             .selectFrom(audioContent) |             .select( | ||||||
|  |                 QGetAudioContentMainItem( | ||||||
|  |                     audioContent.id, | ||||||
|  |                     audioContent.coverImage.prepend("/").prepend(cloudfrontHost), | ||||||
|  |                     audioContent.title, | ||||||
|  |                     audioContent.isAdult, | ||||||
|  |                     member.id, | ||||||
|  |                     member.profileImage.prepend("/").prepend(cloudfrontHost), | ||||||
|  |                     member.nickname | ||||||
|  |                 ) | ||||||
|  |             ) | ||||||
|  |             .from(audioContent) | ||||||
|  |             .innerJoin(audioContent.member, member) | ||||||
|  |             .innerJoin(audioContent.theme, audioContentTheme) | ||||||
|             .where(where) |             .where(where) | ||||||
|             .offset(offset) |             .offset(offset) | ||||||
|             .limit(limit) |             .limit(limit) | ||||||
|   | |||||||
| @@ -1,9 +1,6 @@ | |||||||
| package kr.co.vividnext.sodalive.content.main.curation | package kr.co.vividnext.sodalive.content.main.curation | ||||||
|  |  | ||||||
| import kr.co.vividnext.sodalive.content.GetAudioContentListItem |  | ||||||
| import kr.co.vividnext.sodalive.content.SortType | import kr.co.vividnext.sodalive.content.SortType | ||||||
| import kr.co.vividnext.sodalive.content.comment.AudioContentCommentRepository |  | ||||||
| import kr.co.vividnext.sodalive.content.like.AudioContentLikeRepository |  | ||||||
| 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 | ||||||
| import org.springframework.beans.factory.annotation.Value | import org.springframework.beans.factory.annotation.Value | ||||||
| @@ -14,8 +11,6 @@ import org.springframework.stereotype.Service | |||||||
| class AudioContentCurationService( | class AudioContentCurationService( | ||||||
|     private val repository: AudioContentCurationQueryRepository, |     private val repository: AudioContentCurationQueryRepository, | ||||||
|     private val blockMemberRepository: BlockMemberRepository, |     private val blockMemberRepository: BlockMemberRepository, | ||||||
|     private val commentRepository: AudioContentCommentRepository, |  | ||||||
|     private val audioContentLikeRepository: AudioContentLikeRepository, |  | ||||||
|  |  | ||||||
|     @Value("\${cloud.aws.cloud-front.host}") |     @Value("\${cloud.aws.cloud-front.host}") | ||||||
|     private val cloudFrontHost: String |     private val cloudFrontHost: String | ||||||
| @@ -30,44 +25,19 @@ class AudioContentCurationService( | |||||||
|  |  | ||||||
|         val audioContentList = repository.findByCurationId( |         val audioContentList = repository.findByCurationId( | ||||||
|             curationId = curationId, |             curationId = curationId, | ||||||
|  |             cloudfrontHost = cloudFrontHost, | ||||||
|             isAdult = member.auth != null, |             isAdult = member.auth != null, | ||||||
|             sortType = sortType, |             sortType = sortType, | ||||||
|             offset = pageable.offset, |             offset = pageable.offset, | ||||||
|             limit = pageable.pageSize.toLong() |             limit = pageable.pageSize.toLong() | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
|         val items = audioContentList |  | ||||||
|             .asSequence() |             .asSequence() | ||||||
|             .filter { content -> |             .filter { !blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it.creatorId) } | ||||||
|                 !blockMemberRepository.isBlocked( |  | ||||||
|                     blockedMemberId = member.id!!, |  | ||||||
|                     memberId = content.member!!.id!! |  | ||||||
|                 ) |  | ||||||
|             } |  | ||||||
|             .map { |  | ||||||
|                 val commentCount = commentRepository |  | ||||||
|                     .totalCountCommentByContentId(it.id!!) |  | ||||||
|  |  | ||||||
|                 val likeCount = audioContentLikeRepository |  | ||||||
|                     .totalCountAudioContentLike(it.id!!) |  | ||||||
|  |  | ||||||
|                 GetAudioContentListItem( |  | ||||||
|                     contentId = it.id!!, |  | ||||||
|                     coverImageUrl = "$cloudFrontHost/${it.coverImage!!}", |  | ||||||
|                     title = it.title, |  | ||||||
|                     price = it.price, |  | ||||||
|                     themeStr = it.theme!!.theme, |  | ||||||
|                     duration = it.duration, |  | ||||||
|                     likeCount = likeCount, |  | ||||||
|                     commentCount = commentCount, |  | ||||||
|                     isAdult = it.isAdult |  | ||||||
|                 ) |  | ||||||
|             } |  | ||||||
|             .toList() |             .toList() | ||||||
|  |  | ||||||
|         return GetCurationContentResponse( |         return GetCurationContentResponse( | ||||||
|             totalCount = totalCount, |             totalCount = totalCount, | ||||||
|             items = items |             items = audioContentList | ||||||
|         ) |         ) | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,8 +1,8 @@ | |||||||
| package kr.co.vividnext.sodalive.content.main.curation | package kr.co.vividnext.sodalive.content.main.curation | ||||||
|  |  | ||||||
| import kr.co.vividnext.sodalive.content.GetAudioContentListItem | import kr.co.vividnext.sodalive.content.main.GetAudioContentMainItem | ||||||
|  |  | ||||||
| data class GetCurationContentResponse( | data class GetCurationContentResponse( | ||||||
|     val totalCount: Int, |     val totalCount: Int, | ||||||
|     val items: List<GetAudioContentListItem> |     val items: List<GetAudioContentMainItem> | ||||||
| ) | ) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user