parent
738d7fba2a
commit
7bafb6ba0d
|
@ -43,7 +43,7 @@ interface AudioContentQueryRepository {
|
|||
limit: Long = 10
|
||||
): List<GetAudioContentListItem>
|
||||
|
||||
fun findTotalCountByCreatorId(creatorId: Long, isAdult: Boolean = false): Int
|
||||
fun findTotalCountByCreatorId(creatorId: Long, isAdult: Boolean = false, categoryId: Long = 0): Int
|
||||
fun getCreatorOtherContentList(
|
||||
cloudfrontHost: String,
|
||||
contentId: Long,
|
||||
|
@ -200,7 +200,8 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
|
|||
|
||||
override fun findTotalCountByCreatorId(
|
||||
creatorId: Long,
|
||||
isAdult: Boolean
|
||||
isAdult: Boolean,
|
||||
categoryId: Long
|
||||
): Int {
|
||||
var where = audioContent.member.id.eq(creatorId)
|
||||
.and(
|
||||
|
@ -212,8 +213,15 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
|
|||
where = where.and(audioContent.isAdult.isFalse)
|
||||
}
|
||||
|
||||
if (categoryId > 0) {
|
||||
where = where.and(categoryContent.category.id.eq(categoryId))
|
||||
}
|
||||
|
||||
return queryFactory
|
||||
.selectFrom(audioContent)
|
||||
.select(audioContent.id)
|
||||
.from(audioContent)
|
||||
.leftJoin(categoryContent)
|
||||
.on(audioContent.id.eq(categoryContent.content.id).and(categoryContent.isActive.ne(false)))
|
||||
.where(where)
|
||||
.fetch()
|
||||
.size
|
||||
|
|
|
@ -630,7 +630,8 @@ class AudioContentService(
|
|||
): GetAudioContentListResponse {
|
||||
val totalCount = repository.findTotalCountByCreatorId(
|
||||
creatorId = creatorId,
|
||||
isAdult = member.auth != null
|
||||
isAdult = member.auth != null,
|
||||
categoryId = categoryId
|
||||
)
|
||||
|
||||
val audioContentList = repository.findByCreatorId(
|
||||
|
|
|
@ -20,12 +20,13 @@ import org.springframework.web.multipart.MultipartFile
|
|||
class CreatorAdminContentController(private val service: CreatorAdminContentService) {
|
||||
@GetMapping("/list")
|
||||
fun getAudioContentList(
|
||||
pageable: Pageable,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
@RequestParam("category-id", required = false) categoryId: Long? = 0,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||
pageable: Pageable
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
|
||||
ApiResponse.ok(service.getAudioContentList(pageable, member))
|
||||
ApiResponse.ok(service.getAudioContentList(pageable, member, categoryId ?: 0))
|
||||
}
|
||||
|
||||
@GetMapping("/search")
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.querydsl.core.types.dsl.StringTemplate
|
|||
import com.querydsl.jpa.impl.JPAQueryFactory
|
||||
import kr.co.vividnext.sodalive.content.AudioContent
|
||||
import kr.co.vividnext.sodalive.content.QAudioContent.audioContent
|
||||
import kr.co.vividnext.sodalive.content.category.QCategoryContent.categoryContent
|
||||
import kr.co.vividnext.sodalive.content.hashtag.QAudioContentHashTag.audioContentHashTag
|
||||
import kr.co.vividnext.sodalive.content.hashtag.QHashTag.hashTag
|
||||
import kr.co.vividnext.sodalive.content.theme.QAudioContentTheme.audioContentTheme
|
||||
|
@ -16,11 +17,12 @@ import java.time.LocalDateTime
|
|||
interface CreatorAdminContentRepository : JpaRepository<AudioContent, Long>, CreatorAdminAudioContentQueryRepository
|
||||
|
||||
interface CreatorAdminAudioContentQueryRepository {
|
||||
fun getAudioContentTotalCount(memberId: Long, searchWord: String = ""): Int
|
||||
fun getAudioContentTotalCount(memberId: Long, searchWord: String = "", categoryId: Long = 0): Int
|
||||
fun getAudioContentList(
|
||||
memberId: Long,
|
||||
offset: Long,
|
||||
limit: Long,
|
||||
categoryId: Long = 0,
|
||||
searchWord: String = ""
|
||||
): List<GetCreatorAdminContentListItem>
|
||||
|
||||
|
@ -32,7 +34,7 @@ interface CreatorAdminAudioContentQueryRepository {
|
|||
class CreatorAdminAudioContentQueryRepositoryImpl(
|
||||
private val queryFactory: JPAQueryFactory
|
||||
) : CreatorAdminAudioContentQueryRepository {
|
||||
override fun getAudioContentTotalCount(memberId: Long, searchWord: String): Int {
|
||||
override fun getAudioContentTotalCount(memberId: Long, searchWord: String, categoryId: Long): Int {
|
||||
var where = audioContent.duration.isNotNull
|
||||
.and(audioContent.member.isNotNull)
|
||||
.and(audioContent.isActive.isTrue.or(audioContent.releaseDate.isNotNull))
|
||||
|
@ -45,9 +47,15 @@ class CreatorAdminAudioContentQueryRepositoryImpl(
|
|||
)
|
||||
}
|
||||
|
||||
if (categoryId > 0) {
|
||||
where = where.and(categoryContent.category.id.eq(categoryId))
|
||||
}
|
||||
|
||||
return queryFactory
|
||||
.select(audioContent.id)
|
||||
.from(audioContent)
|
||||
.leftJoin(categoryContent)
|
||||
.on(audioContent.id.eq(categoryContent.content.id).and(categoryContent.isActive.ne(false)))
|
||||
.where(where)
|
||||
.fetch()
|
||||
.size
|
||||
|
@ -57,6 +65,7 @@ class CreatorAdminAudioContentQueryRepositoryImpl(
|
|||
memberId: Long,
|
||||
offset: Long,
|
||||
limit: Long,
|
||||
categoryId: Long,
|
||||
searchWord: String
|
||||
): List<GetCreatorAdminContentListItem> {
|
||||
var where = audioContent.duration.isNotNull
|
||||
|
@ -64,6 +73,10 @@ class CreatorAdminAudioContentQueryRepositoryImpl(
|
|||
.and(audioContent.isActive.isTrue.or(audioContent.releaseDate.isNotNull))
|
||||
.and(audioContent.member.id.eq(memberId))
|
||||
|
||||
if (categoryId > 0) {
|
||||
where = where.and(categoryContent.category.id.eq(categoryId))
|
||||
}
|
||||
|
||||
if (searchWord.trim().length > 1) {
|
||||
where = where.and(
|
||||
audioContent.title.contains(searchWord)
|
||||
|
@ -91,6 +104,8 @@ class CreatorAdminAudioContentQueryRepositoryImpl(
|
|||
)
|
||||
.from(audioContent)
|
||||
.innerJoin(audioContent.theme, audioContentTheme)
|
||||
.leftJoin(categoryContent)
|
||||
.on(audioContent.id.eq(categoryContent.content.id).and(categoryContent.isActive.ne(false)))
|
||||
.where(where)
|
||||
.offset(offset)
|
||||
.limit(limit)
|
||||
|
|
|
@ -26,12 +26,13 @@ class CreatorAdminContentService(
|
|||
@Value("\${cloud.aws.cloud-front.host}")
|
||||
private val coverImageHost: String
|
||||
) {
|
||||
fun getAudioContentList(pageable: Pageable, member: Member): GetCreatorAdminContentListResponse {
|
||||
val totalCount = repository.getAudioContentTotalCount(memberId = member.id!!)
|
||||
fun getAudioContentList(pageable: Pageable, member: Member, categoryId: Long): GetCreatorAdminContentListResponse {
|
||||
val totalCount = repository.getAudioContentTotalCount(memberId = member.id!!, categoryId = categoryId)
|
||||
val audioContentAndThemeList = repository.getAudioContentList(
|
||||
memberId = member.id!!,
|
||||
offset = pageable.offset,
|
||||
limit = pageable.pageSize.toLong()
|
||||
limit = pageable.pageSize.toLong(),
|
||||
categoryId = categoryId
|
||||
)
|
||||
|
||||
val audioContentList = audioContentAndThemeList
|
||||
|
|
Loading…
Reference in New Issue