feat(content-sort-type): getLatestContentByTheme(테마별 콘텐츠 조회)시 정렬 타입 추가

This commit is contained in:
2025-11-20 00:26:24 +09:00
parent b6eb13df06
commit 88d90eec2f
3 changed files with 24 additions and 2 deletions

View File

@@ -243,6 +243,8 @@ class AudioContentController(private val service: AudioContentService) {
@RequestParam("contentType", required = false) contentType: ContentType? = null, @RequestParam("contentType", required = false) contentType: ContentType? = null,
@RequestParam("isFree", required = false) isFree: Boolean? = null, @RequestParam("isFree", required = false) isFree: Boolean? = null,
@RequestParam("isPointAvailableOnly", required = false) isPointAvailableOnly: Boolean? = null, @RequestParam("isPointAvailableOnly", required = false) isPointAvailableOnly: Boolean? = null,
@RequestParam("sort-type", required = false) sortType: SortType? = SortType.NEWEST,
@RequestParam("theme", required = false) theme: String? = null,
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?, @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
pageable: Pageable pageable: Pageable
) = run { ) = run {
@@ -250,10 +252,11 @@ class AudioContentController(private val service: AudioContentService) {
ApiResponse.ok( ApiResponse.ok(
service.getLatestContentByTheme( service.getLatestContentByTheme(
theme = emptyList(), theme = if (theme == null) listOf() else listOf(theme),
contentType = contentType ?: ContentType.ALL, contentType = contentType ?: ContentType.ALL,
offset = pageable.offset, offset = pageable.offset,
limit = pageable.pageSize.toLong(), limit = pageable.pageSize.toLong(),
sortType = sortType ?: SortType.NEWEST,
isFree = isFree ?: false, isFree = isFree ?: false,
isAdult = (isAdultContentVisible ?: true) && member.auth != null, isAdult = (isAdultContentVisible ?: true) && member.auth != null,
isPointAvailableOnly = isPointAvailableOnly ?: false isPointAvailableOnly = isPointAvailableOnly ?: false

View File

@@ -180,6 +180,7 @@ interface AudioContentQueryRepository {
contentType: ContentType, contentType: ContentType,
offset: Long, offset: Long,
limit: Long, limit: Long,
sortType: SortType,
isFree: Boolean, isFree: Boolean,
isAdult: Boolean, isAdult: Boolean,
orderByRandom: Boolean = false, orderByRandom: Boolean = false,
@@ -1304,6 +1305,7 @@ class AudioContentQueryRepositoryImpl(
contentType: ContentType, contentType: ContentType,
offset: Long, offset: Long,
limit: Long, limit: Long,
sortType: SortType,
isFree: Boolean, isFree: Boolean,
isAdult: Boolean, isAdult: Boolean,
orderByRandom: Boolean, orderByRandom: Boolean,
@@ -1349,7 +1351,22 @@ class AudioContentQueryRepositoryImpl(
val orderBy = if (orderByRandom) { val orderBy = if (orderByRandom) {
Expressions.numberTemplate(Double::class.java, "function('rand')").asc() Expressions.numberTemplate(Double::class.java, "function('rand')").asc()
} else { } else {
audioContent.releaseDate.desc() when (sortType) {
SortType.NEWEST -> audioContent.releaseDate.desc()
SortType.PRICE_HIGH -> if (isFree) {
audioContent.releaseDate.desc()
} else {
audioContent.price.desc()
}
SortType.PRICE_LOW -> if (isFree) {
audioContent.releaseDate.asc()
} else {
audioContent.price.desc()
}
SortType.POPULARITY -> audioContent.playCount.desc()
}
} }
return queryFactory return queryFactory

View File

@@ -988,6 +988,7 @@ class AudioContentService(
contentType: ContentType, contentType: ContentType,
offset: Long = 0, offset: Long = 0,
limit: Long = 20, limit: Long = 20,
sortType: SortType = SortType.NEWEST,
isFree: Boolean = false, isFree: Boolean = false,
isAdult: Boolean = false, isAdult: Boolean = false,
orderByRandom: Boolean = false, orderByRandom: Boolean = false,
@@ -998,6 +999,7 @@ class AudioContentService(
contentType = contentType, contentType = contentType,
offset = offset, offset = offset,
limit = limit, limit = limit,
sortType = sortType,
isFree = isFree, isFree = isFree,
isAdult = isAdult, isAdult = isAdult,
orderByRandom = orderByRandom, orderByRandom = orderByRandom,