fix(series): 시리즈 리스트 랜덤 정렬로 조회할 수 있도록 기능 추가
This commit is contained in:
@@ -124,7 +124,8 @@ class HomeService(
|
||||
|
||||
val originalAudioDramaList = seriesService.getOriginalAudioDramaList(
|
||||
isAdult = isAdult,
|
||||
contentType = contentType
|
||||
contentType = contentType,
|
||||
orderByRandom = true
|
||||
)
|
||||
|
||||
val auditionList = auditionService.getInProgressAuditionList(isAdult = isAdult)
|
||||
|
||||
@@ -39,6 +39,7 @@ interface ContentSeriesQueryRepository {
|
||||
contentType: ContentType,
|
||||
isOriginal: Boolean,
|
||||
isCompleted: Boolean,
|
||||
orderByRandom: Boolean,
|
||||
offset: Long,
|
||||
limit: Long
|
||||
): List<Series>
|
||||
@@ -65,6 +66,7 @@ interface ContentSeriesQueryRepository {
|
||||
fun getOriginalAudioDramaList(
|
||||
isAdult: Boolean,
|
||||
contentType: ContentType,
|
||||
orderByRandom: Boolean = false,
|
||||
offset: Long = 0,
|
||||
limit: Long = 20
|
||||
): List<Series>
|
||||
@@ -139,6 +141,7 @@ class ContentSeriesQueryRepositoryImpl(
|
||||
contentType: ContentType,
|
||||
isOriginal: Boolean,
|
||||
isCompleted: Boolean,
|
||||
orderByRandom: Boolean,
|
||||
offset: Long,
|
||||
limit: Long
|
||||
): List<Series> {
|
||||
@@ -173,7 +176,9 @@ class ContentSeriesQueryRepositoryImpl(
|
||||
}
|
||||
}
|
||||
|
||||
val orderBy = if (creatorId != null) {
|
||||
val orderBy = if (orderByRandom) {
|
||||
listOf(Expressions.numberTemplate(Double::class.java, "function('rand')").asc())
|
||||
} else if (creatorId != null) {
|
||||
listOf(series.orders.asc(), series.createdAt.asc())
|
||||
} else {
|
||||
listOf(audioContent.releaseDate.max().desc(), series.createdAt.asc())
|
||||
@@ -362,6 +367,7 @@ class ContentSeriesQueryRepositoryImpl(
|
||||
override fun getOriginalAudioDramaList(
|
||||
isAdult: Boolean,
|
||||
contentType: ContentType,
|
||||
orderByRandom: Boolean,
|
||||
offset: Long,
|
||||
limit: Long
|
||||
): List<Series> {
|
||||
@@ -390,7 +396,13 @@ class ContentSeriesQueryRepositoryImpl(
|
||||
.selectFrom(series)
|
||||
.innerJoin(series.member, member)
|
||||
.where(where)
|
||||
.orderBy(series.id.desc())
|
||||
.orderBy(
|
||||
if (orderByRandom) {
|
||||
Expressions.numberTemplate(Double::class.java, "function('rand')").asc()
|
||||
} else {
|
||||
series.id.desc()
|
||||
}
|
||||
)
|
||||
.offset(offset)
|
||||
.limit(limit)
|
||||
.fetch()
|
||||
|
||||
@@ -37,10 +37,11 @@ class ContentSeriesService(
|
||||
fun getOriginalAudioDramaList(
|
||||
isAdult: Boolean,
|
||||
contentType: ContentType,
|
||||
orderByRandom: Boolean = false,
|
||||
offset: Long = 0,
|
||||
limit: Long = 20
|
||||
): List<GetSeriesListResponse.SeriesListItem> {
|
||||
val originalAudioDramaList = repository.getOriginalAudioDramaList(isAdult, contentType, offset, limit)
|
||||
val originalAudioDramaList = repository.getOriginalAudioDramaList(isAdult, contentType, orderByRandom, offset, limit)
|
||||
return seriesToSeriesListItem(originalAudioDramaList, isAdult, contentType)
|
||||
}
|
||||
|
||||
@@ -52,6 +53,7 @@ class ContentSeriesService(
|
||||
creatorId: Long?,
|
||||
isOriginal: Boolean = false,
|
||||
isCompleted: Boolean = false,
|
||||
orderByRandom: Boolean = false,
|
||||
isAdultContentVisible: Boolean,
|
||||
contentType: ContentType,
|
||||
member: Member,
|
||||
@@ -75,6 +77,7 @@ class ContentSeriesService(
|
||||
contentType = contentType,
|
||||
isOriginal = isOriginal,
|
||||
isCompleted = isCompleted,
|
||||
orderByRandom = orderByRandom,
|
||||
offset = offset,
|
||||
limit = limit
|
||||
).filter { !blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it.member!!.id!!) }
|
||||
|
||||
Reference in New Issue
Block a user