콘텐츠 조회

- 조회 조건에 카테고리 추가
This commit is contained in:
Klaus 2024-02-02 20:03:23 +09:00
parent c50f24b755
commit 22f274fd32
3 changed files with 13 additions and 0 deletions

View File

@ -105,6 +105,7 @@ class AudioContentController(private val service: AudioContentService) {
fun getAudioContentList( fun getAudioContentList(
@RequestParam("creator-id") creatorId: Long, @RequestParam("creator-id") creatorId: Long,
@RequestParam("sort-type", required = false) sortType: SortType = SortType.NEWEST, @RequestParam("sort-type", required = false) sortType: SortType = SortType.NEWEST,
@RequestParam("category-id", required = false) categoryId: Long = 0,
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?, @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
pageable: Pageable pageable: Pageable
) = run { ) = run {
@ -114,6 +115,7 @@ class AudioContentController(private val service: AudioContentService) {
service.getAudioContentList( service.getAudioContentList(
creatorId = creatorId, creatorId = creatorId,
sortType = sortType, sortType = sortType,
categoryId = categoryId,
member = member, member = member,
offset = pageable.offset, offset = pageable.offset,
limit = pageable.pageSize.toLong() limit = pageable.pageSize.toLong()

View File

@ -4,6 +4,7 @@ import com.querydsl.core.types.dsl.Expressions
import com.querydsl.jpa.impl.JPAQueryFactory import com.querydsl.jpa.impl.JPAQueryFactory
import kr.co.vividnext.sodalive.content.QAudioContent.audioContent import kr.co.vividnext.sodalive.content.QAudioContent.audioContent
import kr.co.vividnext.sodalive.content.QBundleAudioContent.bundleAudioContent import kr.co.vividnext.sodalive.content.QBundleAudioContent.bundleAudioContent
import kr.co.vividnext.sodalive.content.category.QCategoryContent.categoryContent
import kr.co.vividnext.sodalive.content.comment.QAudioContentComment.audioContentComment import kr.co.vividnext.sodalive.content.comment.QAudioContentComment.audioContentComment
import kr.co.vividnext.sodalive.content.like.QAudioContentLike.audioContentLike import kr.co.vividnext.sodalive.content.like.QAudioContentLike.audioContentLike
import kr.co.vividnext.sodalive.content.main.GetAudioContentMainItem import kr.co.vividnext.sodalive.content.main.GetAudioContentMainItem
@ -37,6 +38,7 @@ interface AudioContentQueryRepository {
coverImageHost: String, coverImageHost: String,
isAdult: Boolean = false, isAdult: Boolean = false,
sortType: SortType = SortType.NEWEST, sortType: SortType = SortType.NEWEST,
categoryId: Long = 0,
offset: Long = 0, offset: Long = 0,
limit: Long = 10 limit: Long = 10
): List<GetAudioContentListItem> ): List<GetAudioContentListItem>
@ -144,6 +146,7 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
coverImageHost: String, coverImageHost: String,
isAdult: Boolean, isAdult: Boolean,
sortType: SortType, sortType: SortType,
categoryId: Long,
offset: Long, offset: Long,
limit: Long limit: Long
): List<GetAudioContentListItem> { ): List<GetAudioContentListItem> {
@ -163,6 +166,10 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
where = where.and(audioContent.isAdult.isFalse) where = where.and(audioContent.isAdult.isFalse)
} }
if (categoryId > 0) {
where = where.and(categoryContent.category.id.eq(categoryId))
}
return queryFactory return queryFactory
.select( .select(
QGetAudioContentListItem( QGetAudioContentListItem(
@ -180,6 +187,8 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
) )
) )
.from(audioContent) .from(audioContent)
.leftJoin(categoryContent)
.on(audioContent.id.eq(categoryContent.content.id).and(categoryContent.isActive.ne(false)))
.leftJoin(pinContent) .leftJoin(pinContent)
.on(audioContent.id.eq(pinContent.content.id).and(pinContent.isActive.ne(false))) .on(audioContent.id.eq(pinContent.content.id).and(pinContent.isActive.ne(false)))
.where(where) .where(where)

View File

@ -624,6 +624,7 @@ class AudioContentService(
creatorId: Long, creatorId: Long,
sortType: SortType, sortType: SortType,
member: Member, member: Member,
categoryId: Long = 0,
offset: Long, offset: Long,
limit: Long limit: Long
): GetAudioContentListResponse { ): GetAudioContentListResponse {
@ -637,6 +638,7 @@ class AudioContentService(
coverImageHost = coverImageHost, coverImageHost = coverImageHost,
isAdult = member.auth != null, isAdult = member.auth != null,
sortType = sortType, sortType = sortType,
categoryId = categoryId,
offset = offset, offset = offset,
limit = limit limit = limit
) )