크리에이터 관리자 카테고리 콘텐츠 리스트 API 추가
This commit is contained in:
parent
354c8c3d4a
commit
286629836c
|
@ -0,0 +1,52 @@
|
||||||
|
package kr.co.vividnext.sodalive.creator.admin.content.category
|
||||||
|
|
||||||
|
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||||
|
import kr.co.vividnext.sodalive.common.SodaException
|
||||||
|
import kr.co.vividnext.sodalive.member.Member
|
||||||
|
import org.springframework.data.domain.Pageable
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize
|
||||||
|
import org.springframework.security.core.annotation.AuthenticationPrincipal
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam
|
||||||
|
import org.springframework.web.bind.annotation.RestController
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@PreAuthorize("hasRole('CREATOR')")
|
||||||
|
@RequestMapping("/creator-admin/content-category")
|
||||||
|
class CreatorAdminCategoryController(private val service: CreatorAdminCategoryService) {
|
||||||
|
@GetMapping("/search")
|
||||||
|
fun searchContentNotInCategory(
|
||||||
|
@RequestParam(value = "category_id") categoryId: Long,
|
||||||
|
@RequestParam(value = "search_word") searchWord: String,
|
||||||
|
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||||
|
) = run {
|
||||||
|
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||||
|
|
||||||
|
ApiResponse.ok(
|
||||||
|
service.searchContentNotInCategory(
|
||||||
|
categoryId = categoryId,
|
||||||
|
searchWord = searchWord,
|
||||||
|
memberId = member.id!!
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
fun getContentInCategory(
|
||||||
|
@RequestParam(value = "category_id") categoryId: Long,
|
||||||
|
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||||
|
pageable: Pageable
|
||||||
|
) = run {
|
||||||
|
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||||
|
|
||||||
|
ApiResponse.ok(
|
||||||
|
service.getContentInCategory(
|
||||||
|
categoryId = categoryId,
|
||||||
|
memberId = member.id!!,
|
||||||
|
offset = pageable.offset,
|
||||||
|
limit = pageable.pageSize.toLong()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
package kr.co.vividnext.sodalive.creator.admin.content.category
|
||||||
|
|
||||||
|
import com.querydsl.jpa.impl.JPAQueryFactory
|
||||||
|
import kr.co.vividnext.sodalive.content.QAudioContent.audioContent
|
||||||
|
import kr.co.vividnext.sodalive.content.category.QCategoryContent.categoryContent
|
||||||
|
import org.springframework.stereotype.Repository
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
class CreatorAdminCategoryRepository(private val queryFactory: JPAQueryFactory) {
|
||||||
|
fun searchContentNotInCategory(
|
||||||
|
categoryId: Long,
|
||||||
|
searchWord: String,
|
||||||
|
memberId: Long
|
||||||
|
): List<SearchContentNotInCategoryResponse> {
|
||||||
|
return queryFactory
|
||||||
|
.select(QSearchContentNotInCategoryResponse(audioContent.id, audioContent.title))
|
||||||
|
.from(audioContent)
|
||||||
|
.leftJoin(categoryContent)
|
||||||
|
.on(audioContent.id.eq(categoryContent.content.id).and(categoryContent.isActive.ne(true)))
|
||||||
|
.where(
|
||||||
|
audioContent.duration.isNotNull
|
||||||
|
.and(audioContent.member.isNotNull)
|
||||||
|
.and(audioContent.member.id.eq(memberId))
|
||||||
|
.and(audioContent.isActive.isTrue.or(audioContent.releaseDate.isNotNull))
|
||||||
|
.and(audioContent.title.contains(searchWord))
|
||||||
|
)
|
||||||
|
.fetch()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getContentInCategory(
|
||||||
|
categoryId: Long,
|
||||||
|
memberId: Long,
|
||||||
|
offset: Long,
|
||||||
|
limit: Long
|
||||||
|
): List<GetContentInCategoryResponse> {
|
||||||
|
return queryFactory
|
||||||
|
.select(QGetContentInCategoryResponse(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
|
||||||
|
.and(audioContent.member.isNotNull)
|
||||||
|
.and(audioContent.member.id.eq(memberId))
|
||||||
|
.and(audioContent.isActive.isTrue.or(audioContent.releaseDate.isNotNull))
|
||||||
|
)
|
||||||
|
.fetch()
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package kr.co.vividnext.sodalive.creator.admin.content.category
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service
|
||||||
|
|
||||||
|
@Service
|
||||||
|
class CreatorAdminCategoryService(private val repository: CreatorAdminCategoryRepository) {
|
||||||
|
fun searchContentNotInCategory(
|
||||||
|
categoryId: Long,
|
||||||
|
searchWord: String,
|
||||||
|
memberId: Long
|
||||||
|
): List<SearchContentNotInCategoryResponse> {
|
||||||
|
return repository.searchContentNotInCategory(
|
||||||
|
categoryId,
|
||||||
|
searchWord,
|
||||||
|
memberId
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getContentInCategory(
|
||||||
|
categoryId: Long,
|
||||||
|
memberId: Long,
|
||||||
|
offset: Long,
|
||||||
|
limit: Long
|
||||||
|
): List<GetContentInCategoryResponse> {
|
||||||
|
return repository.getContentInCategory(
|
||||||
|
categoryId,
|
||||||
|
memberId,
|
||||||
|
offset,
|
||||||
|
limit
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package kr.co.vividnext.sodalive.creator.admin.content.category
|
||||||
|
|
||||||
|
import com.querydsl.core.annotations.QueryProjection
|
||||||
|
|
||||||
|
data class GetContentInCategoryResponse @QueryProjection constructor(
|
||||||
|
val contentId: Long,
|
||||||
|
val title: String,
|
||||||
|
val isAdult: Boolean
|
||||||
|
)
|
|
@ -0,0 +1,8 @@
|
||||||
|
package kr.co.vividnext.sodalive.creator.admin.content.category
|
||||||
|
|
||||||
|
import com.querydsl.core.annotations.QueryProjection
|
||||||
|
|
||||||
|
data class SearchContentNotInCategoryResponse @QueryProjection constructor(
|
||||||
|
val contentId: Long,
|
||||||
|
val title: String
|
||||||
|
)
|
Loading…
Reference in New Issue