콘텐츠 조회

- 조회 조건에 카테고리 추가
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(
@RequestParam("creator-id") creatorId: Long,
@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?,
pageable: Pageable
) = run {
@ -114,6 +115,7 @@ class AudioContentController(private val service: AudioContentService) {
service.getAudioContentList(
creatorId = creatorId,
sortType = sortType,
categoryId = categoryId,
member = member,
offset = pageable.offset,
limit = pageable.pageSize.toLong()

View File

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

View File

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