콘텐츠 메인 단편 탭
- 태그별 추천 단편 API 추가
This commit is contained in:
		| @@ -82,4 +82,15 @@ class AudioContentMainTabContentController(private val service: AudioContentMain | ||||
|             ) | ||||
|         ) | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/recommend-content-by-tag") | ||||
|     fun getRecommendedContentByTag( | ||||
|         @RequestParam tag: String, | ||||
|         @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member? | ||||
|     ) = run { | ||||
|         if (member == null) throw SodaException("로그인 정보를 확인해주세요.") | ||||
|         ApiResponse.ok( | ||||
|             service.getRecommendedContentByTag(memberId = member.id!!, tag = tag) | ||||
|         ) | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -21,6 +21,7 @@ class AudioContentMainTabContentService( | ||||
|     private val audioContentThemeRepository: AudioContentThemeQueryRepository, | ||||
|     private val rankingService: RankingService, | ||||
|     private val eventService: EventService, | ||||
|     private val tagCurationService: ContentMainTabTagCurationService, | ||||
|     private val curationRepository: AudioContentCurationQueryRepository | ||||
| ) { | ||||
|     fun fetchData( | ||||
| @@ -87,6 +88,18 @@ class AudioContentMainTabContentService( | ||||
|             emptyList() | ||||
|         } | ||||
|  | ||||
|         val tagList = if (isAdult) { | ||||
|             tagCurationService.getTagList(isAdult = isAdult) | ||||
|         } else { | ||||
|             emptyList() | ||||
|         } | ||||
|  | ||||
|         val tagCurationContentList = if (tagList.isNotEmpty()) { | ||||
|             tagCurationService.getTagCurationContentList(memberId = memberId, tag = tagList[0]) | ||||
|         } else { | ||||
|             emptyList() | ||||
|         } | ||||
|  | ||||
|         val curationList = curationRepository.findByContentMainTabId(tabId = tabId, isAdult = isAdult) | ||||
|             .map { | ||||
|                 GetContentCurationResponse( | ||||
| @@ -108,6 +121,8 @@ class AudioContentMainTabContentService( | ||||
|             contentRankCreatorList = contentRankCreatorList, | ||||
|             salesCountRankContentList = salesCountRankContentList, | ||||
|             eventBannerList = eventBannerList, | ||||
|             tagList = tagList, | ||||
|             tagCurationContentList = tagCurationContentList, | ||||
|             curationList = curationList | ||||
|         ) | ||||
|     } | ||||
| @@ -156,4 +171,8 @@ class AudioContentMainTabContentService( | ||||
|             isAdult = isAdult | ||||
|         ) | ||||
|     } | ||||
|  | ||||
|     fun getRecommendedContentByTag(memberId: Long, tag: String): List<GetAudioContentMainItem> { | ||||
|         return tagCurationService.getTagCurationContentList(memberId = memberId, tag = tag) | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -0,0 +1,70 @@ | ||||
| package kr.co.vividnext.sodalive.content.main.tab.content | ||||
|  | ||||
| import com.querydsl.jpa.impl.JPAQueryFactory | ||||
| import kr.co.vividnext.sodalive.content.QAudioContent.audioContent | ||||
| import kr.co.vividnext.sodalive.content.main.GetAudioContentMainItem | ||||
| import kr.co.vividnext.sodalive.content.main.QGetAudioContentMainItem | ||||
| import kr.co.vividnext.sodalive.content.main.curation.tag.QContentHashTagCuration.contentHashTagCuration | ||||
| import kr.co.vividnext.sodalive.content.main.curation.tag.QContentHashTagCurationItem.contentHashTagCurationItem | ||||
| import kr.co.vividnext.sodalive.member.QMember.member | ||||
| import kr.co.vividnext.sodalive.member.block.QBlockMember.blockMember | ||||
| import org.springframework.beans.factory.annotation.Value | ||||
| import org.springframework.stereotype.Repository | ||||
|  | ||||
| @Repository | ||||
| class ContentMainTabTagCurationRepository( | ||||
|     private val queryFactory: JPAQueryFactory, | ||||
|  | ||||
|     @Value("\${cloud.aws.cloud-front.host}") | ||||
|     private val imageHost: String | ||||
| ) { | ||||
|     fun getTagList(isAdult: Boolean): List<String> { | ||||
|         var where = contentHashTagCuration.isActive.isTrue | ||||
|  | ||||
|         if (!isAdult) { | ||||
|             where = where.and(contentHashTagCuration.isAdult.isFalse) | ||||
|         } | ||||
|  | ||||
|         return queryFactory | ||||
|             .select(contentHashTagCuration.tag) | ||||
|             .from(contentHashTagCuration) | ||||
|             .where(where) | ||||
|             .orderBy(contentHashTagCuration.orders.asc()) | ||||
|             .fetch() | ||||
|     } | ||||
|  | ||||
|     fun getTagCurationContentList(memberId: Long, tag: String): List<GetAudioContentMainItem> { | ||||
|         val blockMemberCondition = blockMember.member.id.eq(member.id) | ||||
|             .and(blockMember.isActive.isTrue) | ||||
|             .and(blockMember.blockedMember.id.eq(memberId)) | ||||
|  | ||||
|         val where = audioContent.isActive.isTrue | ||||
|             .and(audioContent.duration.isNotNull) | ||||
|             .and(audioContent.limited.isNull) | ||||
|             .and(blockMember.id.isNull) | ||||
|             .and(contentHashTagCurationItem.isActive.isTrue) | ||||
|             .and(contentHashTagCuration.tag.eq(tag)) | ||||
|  | ||||
|         return queryFactory | ||||
|             .select( | ||||
|                 QGetAudioContentMainItem( | ||||
|                     audioContent.id, | ||||
|                     audioContent.coverImage.prepend("/").prepend(imageHost), | ||||
|                     audioContent.title, | ||||
|                     member.id, | ||||
|                     member.profileImage.prepend("/").prepend(imageHost), | ||||
|                     member.nickname, | ||||
|                     audioContent.price, | ||||
|                     audioContent.duration | ||||
|                 ) | ||||
|             ) | ||||
|             .from(contentHashTagCurationItem) | ||||
|             .innerJoin(contentHashTagCurationItem.curation, contentHashTagCuration) | ||||
|             .innerJoin(contentHashTagCurationItem.content, audioContent) | ||||
|             .innerJoin(audioContent.member, member) | ||||
|             .leftJoin(blockMember).on(blockMemberCondition) | ||||
|             .where(where) | ||||
|             .orderBy(contentHashTagCurationItem.orders.asc()) | ||||
|             .fetch() | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,15 @@ | ||||
| package kr.co.vividnext.sodalive.content.main.tab.content | ||||
|  | ||||
| import kr.co.vividnext.sodalive.content.main.GetAudioContentMainItem | ||||
| import org.springframework.stereotype.Service | ||||
|  | ||||
| @Service | ||||
| class ContentMainTabTagCurationService(private val repository: ContentMainTabTagCurationRepository) { | ||||
|     fun getTagList(isAdult: Boolean): List<String> { | ||||
|         return repository.getTagList(isAdult = isAdult) | ||||
|     } | ||||
|  | ||||
|     fun getTagCurationContentList(memberId: Long, tag: String): List<GetAudioContentMainItem> { | ||||
|         return repository.getTagCurationContentList(memberId = memberId, tag = tag) | ||||
|     } | ||||
| } | ||||
| @@ -17,5 +17,7 @@ data class GetContentMainTabContentResponse( | ||||
|     val contentRankCreatorList: List<ContentCreatorResponse>, | ||||
|     val salesCountRankContentList: List<GetAudioContentRankingItem>, | ||||
|     val eventBannerList: GetEventResponse, | ||||
|     val tagList: List<String>, | ||||
|     val tagCurationContentList: List<GetAudioContentMainItem>, | ||||
|     val curationList: List<GetContentCurationResponse> | ||||
| ) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user