feat(home-free-content): 최신 콘텐츠 조회 함수 getLatestContentByTheme에 orderbyRandom flag를 추가하여 랜덤으로 정렬한 후 데이터를 가져올 수 있도록 수정
This commit is contained in:
@@ -165,7 +165,8 @@ class HomeService(
|
||||
),
|
||||
contentType = contentType,
|
||||
isFree = true,
|
||||
isAdult = isAdult
|
||||
isAdult = isAdult,
|
||||
orderByRandom = true
|
||||
).filter {
|
||||
if (memberId != null) {
|
||||
!memberService.isBlocked(blockedMemberId = memberId, memberId = it.creatorId)
|
||||
|
||||
@@ -183,7 +183,8 @@ interface AudioContentQueryRepository {
|
||||
offset: Long,
|
||||
limit: Long,
|
||||
isFree: Boolean,
|
||||
isAdult: Boolean
|
||||
isAdult: Boolean,
|
||||
orderByRandom: Boolean = false
|
||||
): List<AudioContentMainItem>
|
||||
|
||||
fun findContentByCurationId(
|
||||
@@ -1308,7 +1309,8 @@ class AudioContentQueryRepositoryImpl(
|
||||
offset: Long,
|
||||
limit: Long,
|
||||
isFree: Boolean,
|
||||
isAdult: Boolean
|
||||
isAdult: Boolean,
|
||||
orderByRandom: Boolean
|
||||
): List<AudioContentMainItem> {
|
||||
var where = audioContent.isActive.isTrue
|
||||
.and(audioContent.duration.isNotNull)
|
||||
@@ -1343,6 +1345,12 @@ class AudioContentQueryRepositoryImpl(
|
||||
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
|
||||
.select(
|
||||
QAudioContentMainItem(
|
||||
@@ -1360,7 +1368,7 @@ class AudioContentQueryRepositoryImpl(
|
||||
.where(where)
|
||||
.offset(offset)
|
||||
.limit(limit)
|
||||
.orderBy(audioContent.releaseDate.desc())
|
||||
.orderBy(orderBy)
|
||||
.fetch()
|
||||
}
|
||||
|
||||
|
||||
@@ -989,7 +989,8 @@ class AudioContentService(
|
||||
offset: Long = 0,
|
||||
limit: Long = 20,
|
||||
isFree: Boolean = false,
|
||||
isAdult: Boolean = false
|
||||
isAdult: Boolean = false,
|
||||
orderByRandom: Boolean = false
|
||||
): List<AudioContentMainItem> {
|
||||
return repository.getLatestContentByTheme(
|
||||
theme = theme,
|
||||
@@ -997,7 +998,8 @@ class AudioContentService(
|
||||
offset = offset,
|
||||
limit = limit,
|
||||
isFree = isFree,
|
||||
isAdult = isAdult
|
||||
isAdult = isAdult,
|
||||
orderByRandom = orderByRandom
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user