크리에이터 관리자 카테고리 콘텐츠 리스트 API

- 전체 개수 추가
This commit is contained in:
Klaus 2024-02-07 00:26:17 +09:00
parent 286629836c
commit e76eed7274
3 changed files with 32 additions and 6 deletions

View File

@ -27,19 +27,37 @@ class CreatorAdminCategoryRepository(private val queryFactory: JPAQueryFactory)
.fetch() .fetch()
} }
fun getContentInCategoryTotalCount(categoryId: Long, memberId: Long): Int {
return queryFactory
.select(audioContent.id)
.from(audioContent)
.leftJoin(categoryContent)
.on(audioContent.id.eq(categoryContent.content.id).and(categoryContent.isActive.isTrue))
.where(
categoryContent.category.id.eq(categoryId)
.and(audioContent.duration.isNotNull)
.and(audioContent.member.isNotNull)
.and(audioContent.member.id.eq(memberId))
.and(audioContent.isActive.isTrue.or(audioContent.releaseDate.isNotNull))
)
.fetch()
.size
}
fun getContentInCategory( fun getContentInCategory(
categoryId: Long, categoryId: Long,
memberId: Long, memberId: Long,
offset: Long, offset: Long,
limit: Long limit: Long
): List<GetContentInCategoryResponse> { ): List<GetContentInCategoryItem> {
return queryFactory return queryFactory
.select(QGetContentInCategoryResponse(audioContent.id, audioContent.title, audioContent.isAdult)) .select(QGetContentInCategoryItem(audioContent.id, audioContent.title, audioContent.isAdult))
.from(audioContent) .from(audioContent)
.leftJoin(categoryContent) .leftJoin(categoryContent)
.on(audioContent.id.eq(categoryContent.content.id).and(categoryContent.isActive.isTrue)) .on(audioContent.id.eq(categoryContent.content.id).and(categoryContent.isActive.isTrue))
.where( .where(
audioContent.duration.isNotNull categoryContent.category.id.eq(categoryId)
.and(audioContent.duration.isNotNull)
.and(audioContent.member.isNotNull) .and(audioContent.member.isNotNull)
.and(audioContent.member.id.eq(memberId)) .and(audioContent.member.id.eq(memberId))
.and(audioContent.isActive.isTrue.or(audioContent.releaseDate.isNotNull)) .and(audioContent.isActive.isTrue.or(audioContent.releaseDate.isNotNull))

View File

@ -21,12 +21,15 @@ class CreatorAdminCategoryService(private val repository: CreatorAdminCategoryRe
memberId: Long, memberId: Long,
offset: Long, offset: Long,
limit: Long limit: Long
): List<GetContentInCategoryResponse> { ): GetContentInCategoryResponse {
return repository.getContentInCategory( val totalCount = repository.getContentInCategoryTotalCount(categoryId, memberId)
val items = repository.getContentInCategory(
categoryId, categoryId,
memberId, memberId,
offset, offset,
limit limit
) )
return GetContentInCategoryResponse(totalCount, items)
} }
} }

View File

@ -2,7 +2,12 @@ package kr.co.vividnext.sodalive.creator.admin.content.category
import com.querydsl.core.annotations.QueryProjection import com.querydsl.core.annotations.QueryProjection
data class GetContentInCategoryResponse @QueryProjection constructor( data class GetContentInCategoryResponse(
val totalCount: Int,
val items: List<GetContentInCategoryItem>
)
data class GetContentInCategoryItem @QueryProjection constructor(
val contentId: Long, val contentId: Long,
val title: String, val title: String,
val isAdult: Boolean val isAdult: Boolean