Merge pull request 'test' (#290) from test into main

Reviewed-on: #290
This commit is contained in:
klaus 2025-03-19 07:51:25 +00:00
commit 3c616474ff
7 changed files with 91 additions and 33 deletions

View File

@ -175,6 +175,8 @@ class AudioContentController(private val service: AudioContentService) {
@GetMapping("/ranking")
fun getAudioContentRanking(
@RequestParam("sort-type", required = false) sortType: String? = "매출",
@RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null,
@RequestParam("contentType", required = false) contentType: ContentType? = null,
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
pageable: Pageable
) = run {
@ -192,7 +194,8 @@ class AudioContentController(private val service: AudioContentService) {
ApiResponse.ok(
service.getAudioContentRanking(
isAdult = member.auth != null,
isAdult = member.auth != null && (isAdultContentVisible ?: true),
contentType = contentType ?: ContentType.ALL,
startDate = startDate,
endDate = endDate,
offset = pageable.offset,

View File

@ -140,6 +140,7 @@ interface AudioContentQueryRepository {
fun getAudioContentRanking(
cloudfrontHost: String,
isAdult: Boolean,
contentType: ContentType,
startDate: LocalDateTime,
endDate: LocalDateTime,
offset: Long = 0,
@ -922,6 +923,7 @@ class AudioContentQueryRepositoryImpl(
override fun getAudioContentRanking(
cloudfrontHost: String,
isAdult: Boolean,
contentType: ContentType,
startDate: LocalDateTime,
endDate: LocalDateTime,
offset: Long,
@ -938,6 +940,20 @@ class AudioContentQueryRepositoryImpl(
if (!isAdult) {
where = where.and(audioContent.isAdult.isFalse)
} else {
if (contentType != ContentType.ALL) {
where = where.and(
audioContent.member.isNull.or(
audioContent.member.auth.gender.eq(
if (contentType == ContentType.MALE) {
0
} else {
1
}
)
)
)
}
}
var select = queryFactory

View File

@ -759,6 +759,7 @@ class AudioContentService(
)
fun getAudioContentRanking(
isAdult: Boolean,
contentType: ContentType,
startDate: LocalDateTime,
endDate: LocalDateTime,
offset: Long,
@ -774,6 +775,7 @@ class AudioContentService(
startDate = startDate.minusDays(1),
endDate = endDate.minusDays(1),
isAdult = isAdult,
contentType = contentType,
offset = offset,
limit = limit,
sortType = sortType

View File

@ -88,6 +88,7 @@ class AudioContentMainTabContentService(
val contentRankCreatorList = rankingService.fetchCreatorBySellContentCountRankTop20(
memberId = member.id!!,
isAdult = isAdult,
contentType = contentType,
startDate = dailyRankingStartDate,
endDate = dailyRankingEndDate
@ -164,14 +165,22 @@ class AudioContentMainTabContentService(
val dailyRankingEndDate = dailyRankingStartDate
.plusDays(1)
return rankingService.getContentRanking(
memberId = memberId,
isAdult = isAdult,
contentType = contentType,
startDate = dailyRankingStartDate,
endDate = dailyRankingEndDate,
sortType = sortType
)
var loopCount = 0
var contentList: List<GetAudioContentRankingItem>
do {
contentList = rankingService.getContentRanking(
memberId = memberId,
isAdult = isAdult,
contentType = contentType,
startDate = dailyRankingStartDate.minusDays(loopCount * 5L),
endDate = dailyRankingEndDate,
sortType = sortType
)
loopCount++
} while (contentList.size < 5 && loopCount < 5)
return contentList
}
fun getNewContentByTheme(

View File

@ -83,6 +83,7 @@ class AudioContentMainTabHomeService(
val contentRankCreatorList = rankingService.fetchCreatorBySellContentCountRankTop20(
memberId = member.id!!,
isAdult = isAdult,
contentType = contentType,
startDate = startDate.minusDays(1),
endDate = endDate

View File

@ -409,6 +409,7 @@ class RankingRepository(
fun fetchCreatorBySellContentCountRankTop20(
memberId: Long,
isAdult: Boolean,
contentType: ContentType,
startDate: LocalDateTime,
endDate: LocalDateTime
@ -422,7 +423,7 @@ class RankingRepository(
.and(order.createdAt.goe(startDate))
.and(order.createdAt.lt(endDate))
var memberCondition = member.isActive.isTrue
val memberCondition = member.isActive.isTrue
.and(member.role.eq(MemberRole.CREATOR))
.and(member.id.eq(audioContent.member.id))
@ -432,18 +433,22 @@ class RankingRepository(
.and(audioContent.limited.isNull)
.and(blockMember.id.isNull)
if (contentType != ContentType.ALL) {
where = where.and(
audioContent.member.auth.isNull.or(
audioContent.member.auth.gender.eq(
if (contentType == ContentType.MALE) {
0
} else {
1
}
if (!isAdult) {
where = where.and(audioContent.isAdult.isFalse)
} else {
if (contentType != ContentType.ALL) {
where = where.and(
audioContent.member.auth.isNull.or(
audioContent.member.auth.gender.eq(
if (contentType == ContentType.MALE) {
0
} else {
1
}
)
)
)
)
}
}
return queryFactory

View File

@ -49,17 +49,25 @@ class RankingService(
sortType: String = "매출",
theme: String = ""
): List<GetAudioContentRankingItem> {
return repository.getAudioContentRanking(
memberId = memberId,
isAdult = isAdult,
contentType = contentType,
startDate = startDate,
endDate = endDate,
offset = offset,
limit = limit,
sortType = sortType,
theme = theme
)
var loopCount = 0L
var contentList: List<GetAudioContentRankingItem>
do {
contentList = repository.getAudioContentRanking(
memberId = memberId,
isAdult = isAdult,
contentType = contentType,
startDate = startDate.minusWeeks(loopCount),
endDate = endDate,
offset = offset,
limit = limit,
sortType = sortType,
theme = theme
)
loopCount++
} while (contentList.size < 5 && loopCount < 5)
return contentList
}
fun getSeriesRanking(
@ -69,7 +77,20 @@ class RankingService(
startDate: LocalDateTime,
endDate: LocalDateTime
): List<GetSeriesListResponse.SeriesListItem> {
val seriesList = repository.getSeriesRanking(memberId, isAdult, contentType, startDate, endDate)
var loopCount = 0L
var seriesList: List<Series>
do {
seriesList = repository.getSeriesRanking(
memberId = memberId,
isAdult = isAdult,
contentType = contentType,
startDate = startDate.minusWeeks(loopCount),
endDate = endDate
)
loopCount++
} while (seriesList.size < 5 && loopCount < 5)
return seriesToSeriesListItem(seriesList = seriesList, isAdult = isAdult)
}
@ -189,11 +210,12 @@ class RankingService(
fun fetchCreatorBySellContentCountRankTop20(
memberId: Long,
isAdult: Boolean,
contentType: ContentType,
startDate: LocalDateTime,
endDate: LocalDateTime
): List<ContentCreatorResponse> {
return repository.fetchCreatorBySellContentCountRankTop20(memberId, contentType, startDate, endDate)
return repository.fetchCreatorBySellContentCountRankTop20(memberId, isAdult, contentType, startDate, endDate)
}
fun fetchCreatorContentBySalesCountTop4(