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