parent
c3e18d658c
commit
eb5710837b
|
@ -19,7 +19,13 @@ interface AdminContentRepository : JpaRepository<AudioContent, Long>, AdminAudio
|
|||
|
||||
interface AdminAudioContentQueryRepository {
|
||||
fun getAudioContentTotalCount(searchWord: String = ""): Int
|
||||
fun getAudioContentList(offset: Long, limit: Long, searchWord: String = ""): List<GetAdminContentListItem>
|
||||
fun getAudioContentList(
|
||||
imageHost: String,
|
||||
offset: Long,
|
||||
limit: Long,
|
||||
searchWord: String = ""
|
||||
): List<GetAdminContentListItem>
|
||||
|
||||
fun getHashTagList(audioContentId: Long): List<String>
|
||||
}
|
||||
|
||||
|
@ -46,7 +52,12 @@ class AdminAudioContentQueryRepositoryImpl(
|
|||
.size
|
||||
}
|
||||
|
||||
override fun getAudioContentList(offset: Long, limit: Long, searchWord: String): List<GetAdminContentListItem> {
|
||||
override fun getAudioContentList(
|
||||
imageHost: String,
|
||||
offset: Long,
|
||||
limit: Long,
|
||||
searchWord: String
|
||||
): List<GetAdminContentListItem> {
|
||||
var where = audioContent.duration.isNotNull
|
||||
.and(audioContent.member.isNotNull)
|
||||
.and(audioContent.isActive.isTrue.or(audioContent.releaseDate.isNotNull))
|
||||
|
@ -64,9 +75,10 @@ class AdminAudioContentQueryRepositoryImpl(
|
|||
audioContent.id,
|
||||
audioContent.title,
|
||||
audioContent.detail,
|
||||
Expressions.stringTemplate("GROUP_CONCAT({0} SEPARATOR ' '", hashTag.tag),
|
||||
audioContentCuration.title,
|
||||
audioContentCuration.id.nullif(0),
|
||||
audioContent.coverImage,
|
||||
audioContent.coverImage.prepend("/").prepend(imageHost),
|
||||
audioContent.member!!.nickname,
|
||||
audioContentTheme.theme,
|
||||
audioContentTheme.id,
|
||||
|
@ -81,8 +93,11 @@ class AdminAudioContentQueryRepositoryImpl(
|
|||
)
|
||||
.from(audioContent)
|
||||
.leftJoin(audioContent.curation, audioContentCuration)
|
||||
.leftJoin(audioContent.audioContentHashTags, audioContentHashTag)
|
||||
.leftJoin(audioContentHashTag.hashTag, hashTag)
|
||||
.innerJoin(audioContent.theme, audioContentTheme)
|
||||
.where(where)
|
||||
.groupBy(audioContent.id)
|
||||
.offset(offset)
|
||||
.limit(limit)
|
||||
.orderBy(audioContent.releaseDate.desc())
|
||||
|
|
|
@ -23,19 +23,13 @@ class AdminContentService(
|
|||
fun getAudioContentList(pageable: Pageable): GetAdminContentListResponse {
|
||||
val totalCount = repository.getAudioContentTotalCount()
|
||||
val audioContentAndThemeList = repository.getAudioContentList(
|
||||
imageHost = coverImageHost,
|
||||
offset = pageable.offset,
|
||||
limit = pageable.pageSize.toLong()
|
||||
)
|
||||
|
||||
val audioContentList = audioContentAndThemeList
|
||||
.asSequence()
|
||||
.map {
|
||||
val tags = repository
|
||||
.getHashTagList(audioContentId = it.audioContentId)
|
||||
.joinToString(" ") { tag -> tag }
|
||||
it.tags = tags
|
||||
it
|
||||
}
|
||||
.map {
|
||||
it.contentUrl = audioContentCloudFront.generateSignedURL(
|
||||
resourcePath = it.contentUrl,
|
||||
|
@ -43,10 +37,6 @@ class AdminContentService(
|
|||
)
|
||||
it
|
||||
}
|
||||
.map {
|
||||
it.coverImageUrl = "$coverImageHost/${it.coverImageUrl}"
|
||||
it
|
||||
}
|
||||
.toList()
|
||||
|
||||
return GetAdminContentListResponse(totalCount, audioContentList)
|
||||
|
@ -56,6 +46,7 @@ class AdminContentService(
|
|||
if (searchWord.length < 2) throw SodaException("2글자 이상 입력하세요.")
|
||||
val totalCount = repository.getAudioContentTotalCount(searchWord)
|
||||
val audioContentAndThemeList = repository.getAudioContentList(
|
||||
imageHost = coverImageHost,
|
||||
offset = pageable.offset,
|
||||
limit = pageable.pageSize.toLong(),
|
||||
searchWord = searchWord
|
||||
|
@ -63,13 +54,6 @@ class AdminContentService(
|
|||
|
||||
val audioContentList = audioContentAndThemeList
|
||||
.asSequence()
|
||||
.map {
|
||||
val tags = repository
|
||||
.getHashTagList(audioContentId = it.audioContentId)
|
||||
.joinToString(" ") { tag -> tag }
|
||||
it.tags = tags
|
||||
it
|
||||
}
|
||||
.map {
|
||||
it.contentUrl = audioContentCloudFront.generateSignedURL(
|
||||
resourcePath = it.contentUrl,
|
||||
|
@ -77,10 +61,6 @@ class AdminContentService(
|
|||
)
|
||||
it
|
||||
}
|
||||
.map {
|
||||
it.coverImageUrl = "$coverImageHost/${it.coverImageUrl}"
|
||||
it
|
||||
}
|
||||
.toList()
|
||||
|
||||
return GetAdminContentListResponse(totalCount, audioContentList)
|
||||
|
|
|
@ -11,6 +11,7 @@ data class GetAdminContentListItem @QueryProjection constructor(
|
|||
val audioContentId: Long,
|
||||
val title: String,
|
||||
val detail: String,
|
||||
var tags: String,
|
||||
val curationTitle: String?,
|
||||
val curationId: Long,
|
||||
var coverImageUrl: String,
|
||||
|
@ -24,6 +25,4 @@ data class GetAdminContentListItem @QueryProjection constructor(
|
|||
val isCommentAvailable: Boolean,
|
||||
val date: String,
|
||||
val releaseDate: String?
|
||||
) {
|
||||
var tags: String = ""
|
||||
}
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue