Merge pull request '콘텐츠 메인 - 새로운 콘텐츠 섹션 두번째 정렬 조건 추가' (#220) from test into main

Reviewed-on: #220
This commit is contained in:
klaus 2024-10-04 07:21:38 +00:00
commit efe8f4f939
1 changed files with 14 additions and 5 deletions

View File

@ -337,9 +337,18 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
limit: Long limit: Long
): List<GetAudioContentMainItem> { ): List<GetAudioContentMainItem> {
val orderBy = when (sortType) { val orderBy = when (sortType) {
SortType.NEWEST -> audioContent.releaseDate.desc() SortType.NEWEST -> listOf(audioContent.releaseDate.desc(), audioContent.id.desc())
SortType.PRICE_HIGH -> audioContent.price.desc() SortType.PRICE_HIGH -> listOf(
SortType.PRICE_LOW -> audioContent.price.asc() audioContent.price.desc(),
audioContent.releaseDate.desc(),
audioContent.id.desc()
)
SortType.PRICE_LOW -> listOf(
audioContent.price.asc(),
audioContent.releaseDate.asc(),
audioContent.id.asc()
)
} }
var where = audioContent.isActive.isTrue var where = audioContent.isActive.isTrue
@ -377,7 +386,7 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
.where(where) .where(where)
.offset(offset) .offset(offset)
.limit(limit) .limit(limit)
.orderBy(orderBy) .orderBy(*orderBy.toTypedArray())
.fetch() .fetch()
} }
@ -480,7 +489,7 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
.where(where) .where(where)
.offset(offset) .offset(offset)
.limit(limit) .limit(limit)
.orderBy(audioContent.releaseDate.desc()) .orderBy(audioContent.releaseDate.desc(), audioContent.id.desc())
.fetch() .fetch()
} }