Compare commits
No commits in common. "5f3b1663d2a147c9f058dca520363d823c753942" and "66e786b4bb6c7d7e083a40377be377a114d188b4" have entirely different histories.
5f3b1663d2
...
66e786b4bb
|
@ -15,39 +15,16 @@ import org.springframework.web.bind.annotation.RestController
|
|||
@RequestMapping("/admin/audio-content")
|
||||
class AdminContentController(private val service: AdminContentService) {
|
||||
@GetMapping("/list")
|
||||
fun getAudioContentList(
|
||||
@RequestParam(value = "status", required = false) status: ContentReleaseStatus?,
|
||||
pageable: Pageable
|
||||
) = ApiResponse.ok(
|
||||
service.getAudioContentList(
|
||||
status = status ?: ContentReleaseStatus.OPEN,
|
||||
pageable
|
||||
)
|
||||
)
|
||||
fun getAudioContentList(pageable: Pageable) = ApiResponse.ok(service.getAudioContentList(pageable))
|
||||
|
||||
@GetMapping("/search")
|
||||
fun searchAudioContent(
|
||||
@RequestParam(value = "status", required = false) status: ContentReleaseStatus?,
|
||||
@RequestParam(value = "search_word") searchWord: String,
|
||||
pageable: Pageable
|
||||
) = ApiResponse.ok(
|
||||
service.searchAudioContent(
|
||||
status = status ?: ContentReleaseStatus.OPEN,
|
||||
searchWord,
|
||||
pageable
|
||||
)
|
||||
)
|
||||
) = ApiResponse.ok(service.searchAudioContent(searchWord, pageable))
|
||||
|
||||
@PutMapping
|
||||
fun modifyAudioContent(
|
||||
@RequestBody request: UpdateAdminContentRequest
|
||||
) = ApiResponse.ok(service.updateAudioContent(request))
|
||||
}
|
||||
|
||||
enum class ContentReleaseStatus {
|
||||
// 콘텐츠가 공개된 상태
|
||||
OPEN,
|
||||
|
||||
// 예약된 콘텐츠, 아직 공개되지 않은 상태
|
||||
SCHEDULED
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ import kr.co.vividnext.sodalive.content.hashtag.QAudioContentHashTag.audioConten
|
|||
import kr.co.vividnext.sodalive.content.hashtag.QHashTag.hashTag
|
||||
import kr.co.vividnext.sodalive.content.main.curation.QAudioContentCuration.audioContentCuration
|
||||
import kr.co.vividnext.sodalive.content.theme.QAudioContentTheme.audioContentTheme
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
import org.springframework.data.jpa.repository.JpaRepository
|
||||
import org.springframework.stereotype.Repository
|
||||
import java.time.LocalDateTime
|
||||
|
@ -19,13 +18,9 @@ import java.time.LocalDateTime
|
|||
interface AdminContentRepository : JpaRepository<AudioContent, Long>, AdminAudioContentQueryRepository
|
||||
|
||||
interface AdminAudioContentQueryRepository {
|
||||
fun getAudioContentTotalCount(
|
||||
searchWord: String = "",
|
||||
status: ContentReleaseStatus = ContentReleaseStatus.OPEN
|
||||
): Int
|
||||
|
||||
fun getAudioContentTotalCount(searchWord: String = ""): Int
|
||||
fun getAudioContentList(
|
||||
status: ContentReleaseStatus = ContentReleaseStatus.OPEN,
|
||||
imageHost: String,
|
||||
offset: Long,
|
||||
limit: Long,
|
||||
searchWord: String = ""
|
||||
|
@ -35,17 +30,9 @@ interface AdminAudioContentQueryRepository {
|
|||
}
|
||||
|
||||
class AdminAudioContentQueryRepositoryImpl(
|
||||
private val queryFactory: JPAQueryFactory,
|
||||
|
||||
@Value("\${cloud.aws.cloud-front.host}")
|
||||
private val imageHost: String
|
||||
private val queryFactory: JPAQueryFactory
|
||||
) : AdminAudioContentQueryRepository {
|
||||
override fun getAudioContentTotalCount(
|
||||
searchWord: String,
|
||||
status: ContentReleaseStatus
|
||||
): Int {
|
||||
val now = LocalDateTime.now()
|
||||
|
||||
override fun getAudioContentTotalCount(searchWord: String): Int {
|
||||
var where = audioContent.duration.isNotNull
|
||||
.and(audioContent.member.isNotNull)
|
||||
.and(audioContent.isActive.isTrue.or(audioContent.releaseDate.isNotNull))
|
||||
|
@ -57,12 +44,6 @@ class AdminAudioContentQueryRepositoryImpl(
|
|||
)
|
||||
}
|
||||
|
||||
where = if (status == ContentReleaseStatus.SCHEDULED) {
|
||||
where.and(audioContent.releaseDate.after(now))
|
||||
} else {
|
||||
where.and(audioContent.releaseDate.before(now))
|
||||
}
|
||||
|
||||
return queryFactory
|
||||
.select(audioContent.id)
|
||||
.from(audioContent)
|
||||
|
@ -72,13 +53,11 @@ class AdminAudioContentQueryRepositoryImpl(
|
|||
}
|
||||
|
||||
override fun getAudioContentList(
|
||||
status: ContentReleaseStatus,
|
||||
imageHost: String,
|
||||
offset: Long,
|
||||
limit: Long,
|
||||
searchWord: String
|
||||
): List<GetAdminContentListItem> {
|
||||
val now = LocalDateTime.now()
|
||||
|
||||
var where = audioContent.duration.isNotNull
|
||||
.and(audioContent.member.isNotNull)
|
||||
.and(audioContent.isActive.isTrue.or(audioContent.releaseDate.isNotNull))
|
||||
|
@ -90,12 +69,6 @@ class AdminAudioContentQueryRepositoryImpl(
|
|||
)
|
||||
}
|
||||
|
||||
where = if (status == ContentReleaseStatus.SCHEDULED) {
|
||||
where.and(audioContent.releaseDate.after(now))
|
||||
} else {
|
||||
where.and(audioContent.releaseDate.before(now))
|
||||
}
|
||||
|
||||
return queryFactory
|
||||
.select(
|
||||
QGetAdminContentListItem(
|
||||
|
|
|
@ -4,6 +4,7 @@ import kr.co.vividnext.sodalive.admin.content.curation.AdminContentCurationRepos
|
|||
import kr.co.vividnext.sodalive.admin.content.theme.AdminContentThemeRepository
|
||||
import kr.co.vividnext.sodalive.aws.cloudfront.AudioContentCloudFront
|
||||
import kr.co.vividnext.sodalive.common.SodaException
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
import org.springframework.data.domain.Pageable
|
||||
import org.springframework.data.repository.findByIdOrNull
|
||||
import org.springframework.stereotype.Service
|
||||
|
@ -14,17 +15,21 @@ class AdminContentService(
|
|||
private val repository: AdminContentRepository,
|
||||
private val themeRepository: AdminContentThemeRepository,
|
||||
private val audioContentCloudFront: AudioContentCloudFront,
|
||||
private val curationRepository: AdminContentCurationRepository
|
||||
private val curationRepository: AdminContentCurationRepository,
|
||||
|
||||
@Value("\${cloud.aws.cloud-front.host}")
|
||||
private val coverImageHost: String
|
||||
) {
|
||||
fun getAudioContentList(status: ContentReleaseStatus, pageable: Pageable): GetAdminContentListResponse {
|
||||
val totalCount = repository.getAudioContentTotalCount(status = status)
|
||||
fun getAudioContentList(pageable: Pageable): GetAdminContentListResponse {
|
||||
val totalCount = repository.getAudioContentTotalCount()
|
||||
val audioContentAndThemeList = repository.getAudioContentList(
|
||||
status = status,
|
||||
imageHost = coverImageHost,
|
||||
offset = pageable.offset,
|
||||
limit = pageable.pageSize.toLong()
|
||||
)
|
||||
|
||||
val audioContentList = audioContentAndThemeList
|
||||
.asSequence()
|
||||
.map {
|
||||
val tags = repository
|
||||
.getHashTagList(audioContentId = it.audioContentId)
|
||||
|
@ -39,25 +44,23 @@ class AdminContentService(
|
|||
)
|
||||
it
|
||||
}
|
||||
.toList()
|
||||
|
||||
return GetAdminContentListResponse(totalCount, audioContentList)
|
||||
}
|
||||
|
||||
fun searchAudioContent(
|
||||
status: ContentReleaseStatus,
|
||||
searchWord: String,
|
||||
pageable: Pageable
|
||||
): GetAdminContentListResponse {
|
||||
fun searchAudioContent(searchWord: String, pageable: Pageable): GetAdminContentListResponse {
|
||||
if (searchWord.length < 2) throw SodaException("2글자 이상 입력하세요.")
|
||||
val totalCount = repository.getAudioContentTotalCount(searchWord, status = status)
|
||||
val totalCount = repository.getAudioContentTotalCount(searchWord)
|
||||
val audioContentAndThemeList = repository.getAudioContentList(
|
||||
status = status,
|
||||
imageHost = coverImageHost,
|
||||
offset = pageable.offset,
|
||||
limit = pageable.pageSize.toLong(),
|
||||
searchWord = searchWord
|
||||
)
|
||||
|
||||
val audioContentList = audioContentAndThemeList
|
||||
.asSequence()
|
||||
.map {
|
||||
val tags = repository
|
||||
.getHashTagList(audioContentId = it.audioContentId)
|
||||
|
@ -72,6 +75,7 @@ class AdminContentService(
|
|||
)
|
||||
it
|
||||
}
|
||||
.toList()
|
||||
|
||||
return GetAdminContentListResponse(totalCount, audioContentList)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue