feat(home-free-content): 최신 콘텐츠 조회 함수 getLatestContentByTheme에 orderbyRandom flag를 추가하여 랜덤으로 정렬한 후 데이터를 가져올 수 있도록 수정

This commit is contained in:
2025-11-10 12:14:24 +09:00
parent 5ca666c7fa
commit eab7dc4521
3 changed files with 17 additions and 6 deletions

View File

@@ -165,7 +165,8 @@ class HomeService(
), ),
contentType = contentType, contentType = contentType,
isFree = true, isFree = true,
isAdult = isAdult isAdult = isAdult,
orderByRandom = true
).filter { ).filter {
if (memberId != null) { if (memberId != null) {
!memberService.isBlocked(blockedMemberId = memberId, memberId = it.creatorId) !memberService.isBlocked(blockedMemberId = memberId, memberId = it.creatorId)

View File

@@ -183,7 +183,8 @@ interface AudioContentQueryRepository {
offset: Long, offset: Long,
limit: Long, limit: Long,
isFree: Boolean, isFree: Boolean,
isAdult: Boolean isAdult: Boolean,
orderByRandom: Boolean = false
): List<AudioContentMainItem> ): List<AudioContentMainItem>
fun findContentByCurationId( fun findContentByCurationId(
@@ -1308,7 +1309,8 @@ class AudioContentQueryRepositoryImpl(
offset: Long, offset: Long,
limit: Long, limit: Long,
isFree: Boolean, isFree: Boolean,
isAdult: Boolean isAdult: Boolean,
orderByRandom: Boolean
): List<AudioContentMainItem> { ): List<AudioContentMainItem> {
var where = audioContent.isActive.isTrue var where = audioContent.isActive.isTrue
.and(audioContent.duration.isNotNull) .and(audioContent.duration.isNotNull)
@@ -1343,6 +1345,12 @@ class AudioContentQueryRepositoryImpl(
where = where.and(audioContent.price.loe(0)) where = where.and(audioContent.price.loe(0))
} }
val orderBy = if (orderByRandom) {
Expressions.numberTemplate(Double::class.java, "function('rand')").asc()
} else {
audioContent.releaseDate.desc()
}
return queryFactory return queryFactory
.select( .select(
QAudioContentMainItem( QAudioContentMainItem(
@@ -1360,7 +1368,7 @@ class AudioContentQueryRepositoryImpl(
.where(where) .where(where)
.offset(offset) .offset(offset)
.limit(limit) .limit(limit)
.orderBy(audioContent.releaseDate.desc()) .orderBy(orderBy)
.fetch() .fetch()
} }

View File

@@ -989,7 +989,8 @@ class AudioContentService(
offset: Long = 0, offset: Long = 0,
limit: Long = 20, limit: Long = 20,
isFree: Boolean = false, isFree: Boolean = false,
isAdult: Boolean = false isAdult: Boolean = false,
orderByRandom: Boolean = false
): List<AudioContentMainItem> { ): List<AudioContentMainItem> {
return repository.getLatestContentByTheme( return repository.getLatestContentByTheme(
theme = theme, theme = theme,
@@ -997,7 +998,8 @@ class AudioContentService(
offset = offset, offset = offset,
limit = limit, limit = limit,
isFree = isFree, isFree = isFree,
isAdult = isAdult isAdult = isAdult,
orderByRandom = orderByRandom
) )
} }
} }