parent
286629836c
commit
e76eed7274
|
@ -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))
|
||||||
|
|
|
@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue