From e76eed72744047281b8e42ee197e15c3a08f5896 Mon Sep 17 00:00:00 2001 From: Klaus Date: Wed, 7 Feb 2024 00:26:17 +0900 Subject: [PATCH] =?UTF-8?q?=ED=81=AC=EB=A6=AC=EC=97=90=EC=9D=B4=ED=84=B0?= =?UTF-8?q?=20=EA=B4=80=EB=A6=AC=EC=9E=90=20=EC=B9=B4=ED=85=8C=EA=B3=A0?= =?UTF-8?q?=EB=A6=AC=20=EC=BD=98=ED=85=90=EC=B8=A0=20=EB=A6=AC=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20API=20-=20=EC=A0=84=EC=B2=B4=20=EA=B0=9C=EC=88=98?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CreatorAdminCategoryRepository.kt | 24 ++++++++++++++++--- .../category/CreatorAdminCategoryService.kt | 7 ++++-- .../category/GetContentInCategoryResponse.kt | 7 +++++- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/creator/admin/content/category/CreatorAdminCategoryRepository.kt b/src/main/kotlin/kr/co/vividnext/sodalive/creator/admin/content/category/CreatorAdminCategoryRepository.kt index 013c15a..2d4e76f 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/creator/admin/content/category/CreatorAdminCategoryRepository.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/creator/admin/content/category/CreatorAdminCategoryRepository.kt @@ -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 { + ): List { 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)) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/creator/admin/content/category/CreatorAdminCategoryService.kt b/src/main/kotlin/kr/co/vividnext/sodalive/creator/admin/content/category/CreatorAdminCategoryService.kt index 45021f6..5531a28 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/creator/admin/content/category/CreatorAdminCategoryService.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/creator/admin/content/category/CreatorAdminCategoryService.kt @@ -21,12 +21,15 @@ class CreatorAdminCategoryService(private val repository: CreatorAdminCategoryRe memberId: Long, offset: Long, limit: Long - ): List { - return repository.getContentInCategory( + ): GetContentInCategoryResponse { + val totalCount = repository.getContentInCategoryTotalCount(categoryId, memberId) + val items = repository.getContentInCategory( categoryId, memberId, offset, limit ) + + return GetContentInCategoryResponse(totalCount, items) } } diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/creator/admin/content/category/GetContentInCategoryResponse.kt b/src/main/kotlin/kr/co/vividnext/sodalive/creator/admin/content/category/GetContentInCategoryResponse.kt index 4891a87..b7d2ebb 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/creator/admin/content/category/GetContentInCategoryResponse.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/creator/admin/content/category/GetContentInCategoryResponse.kt @@ -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 +) + +data class GetContentInCategoryItem @QueryProjection constructor( val contentId: Long, val title: String, val isAdult: Boolean