feat(chat-character): 보온 주간 차트 콘텐츠 정렬 기준 추가
- 매출, 판매량, 댓글 수, 좋아요 수, 후원
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
package kr.co.vividnext.sodalive.rank
|
||||
|
||||
/**
|
||||
* 콘텐츠 랭킹 정렬 기준
|
||||
*/
|
||||
enum class ContentRankingSortType {
|
||||
// 매출: order.can.sum.desc
|
||||
REVENUE,
|
||||
|
||||
// 판매량: order.id.count.desc
|
||||
SALES_COUNT,
|
||||
|
||||
// 댓글 수: audioContentComment.id.count.desc
|
||||
COMMENT_COUNT,
|
||||
|
||||
// 좋아요 수: audioContentLike.id.count.desc
|
||||
LIKE_COUNT,
|
||||
|
||||
// 후원: audioContentComment.donationCan.sum.desc
|
||||
DONATION
|
||||
}
|
||||
@@ -132,6 +132,14 @@ class RankingRepository(
|
||||
.innerJoin(audioContent.theme, audioContentTheme)
|
||||
}
|
||||
|
||||
"판매량" -> {
|
||||
select
|
||||
.from(order)
|
||||
.innerJoin(order.audioContent, audioContent)
|
||||
.innerJoin(audioContent.member, member)
|
||||
.innerJoin(audioContent.theme, audioContentTheme)
|
||||
}
|
||||
|
||||
else -> {
|
||||
select
|
||||
.from(order)
|
||||
@@ -184,6 +192,18 @@ class RankingRepository(
|
||||
.orderBy(audioContentLike.id.count().desc(), audioContent.createdAt.asc())
|
||||
}
|
||||
|
||||
"판매량" -> {
|
||||
select
|
||||
.where(
|
||||
where
|
||||
.and(order.isActive.isTrue)
|
||||
.and(order.createdAt.goe(startDate))
|
||||
.and(order.createdAt.lt(endDate))
|
||||
)
|
||||
.groupBy(audioContent.id)
|
||||
.orderBy(order.id.count().desc(), audioContent.createdAt.asc())
|
||||
}
|
||||
|
||||
else -> {
|
||||
select
|
||||
.where(
|
||||
|
||||
@@ -76,6 +76,38 @@ class RankingService(
|
||||
return contentList
|
||||
}
|
||||
|
||||
private fun toSortString(sort: ContentRankingSortType): String = when (sort) {
|
||||
ContentRankingSortType.REVENUE -> "매출"
|
||||
ContentRankingSortType.SALES_COUNT -> "판매량"
|
||||
ContentRankingSortType.COMMENT_COUNT -> "댓글"
|
||||
ContentRankingSortType.LIKE_COUNT -> "좋아요"
|
||||
ContentRankingSortType.DONATION -> "후원"
|
||||
}
|
||||
|
||||
fun getContentRanking(
|
||||
memberId: Long?,
|
||||
isAdult: Boolean,
|
||||
contentType: ContentType,
|
||||
startDate: LocalDateTime,
|
||||
endDate: LocalDateTime,
|
||||
offset: Long = 0,
|
||||
limit: Long = 12,
|
||||
sort: ContentRankingSortType,
|
||||
theme: String = ""
|
||||
): List<GetAudioContentRankingItem> {
|
||||
return getContentRanking(
|
||||
memberId = memberId,
|
||||
isAdult = isAdult,
|
||||
contentType = contentType,
|
||||
startDate = startDate,
|
||||
endDate = endDate,
|
||||
offset = offset,
|
||||
limit = limit,
|
||||
sortType = toSortString(sort),
|
||||
theme = theme
|
||||
)
|
||||
}
|
||||
|
||||
fun getSeriesRanking(
|
||||
memberId: Long?,
|
||||
isAdult: Boolean,
|
||||
|
||||
Reference in New Issue
Block a user