크리에이터 관리자 카테고리 콘텐츠 리스트 API
- 전체 개수 추가
This commit is contained in:
		| @@ -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)) | ||||
|   | ||||
| @@ -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) | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user