크리에이터 관리자 카테고리 콘텐츠 리스트 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()
}
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(
categoryId: Long,
memberId: Long,
offset: Long,
limit: Long
): List<GetContentInCategoryResponse> {
): List<GetContentInCategoryItem> {
return queryFactory
.select(QGetContentInCategoryResponse(audioContent.id, audioContent.title, audioContent.isAdult))
.select(QGetContentInCategoryItem(audioContent.id, audioContent.title, audioContent.isAdult))
.from(audioContent)
.leftJoin(categoryContent)
.on(audioContent.id.eq(categoryContent.content.id).and(categoryContent.isActive.isTrue))
.where(
audioContent.duration.isNotNull
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))

View File

@ -21,12 +21,15 @@ class CreatorAdminCategoryService(private val repository: CreatorAdminCategoryRe
memberId: Long,
offset: Long,
limit: Long
): List<GetContentInCategoryResponse> {
return repository.getContentInCategory(
): GetContentInCategoryResponse {
val totalCount = repository.getContentInCategoryTotalCount(categoryId, memberId)
val items = repository.getContentInCategory(
categoryId,
memberId,
offset,
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
data class GetContentInCategoryResponse @QueryProjection constructor(
data class GetContentInCategoryResponse(
val totalCount: Int,
val items: List<GetContentInCategoryItem>
)
data class GetContentInCategoryItem @QueryProjection constructor(
val contentId: Long,
val title: String,
val isAdult: Boolean