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

View File

@ -140,6 +140,7 @@ interface AudioContentQueryRepository {
fun getAudioContentRanking( fun getAudioContentRanking(
cloudfrontHost: String, cloudfrontHost: String,
isAdult: Boolean, isAdult: Boolean,
contentType: ContentType,
startDate: LocalDateTime, startDate: LocalDateTime,
endDate: LocalDateTime, endDate: LocalDateTime,
offset: Long = 0, offset: Long = 0,
@ -922,6 +923,7 @@ class AudioContentQueryRepositoryImpl(
override fun getAudioContentRanking( override fun getAudioContentRanking(
cloudfrontHost: String, cloudfrontHost: String,
isAdult: Boolean, isAdult: Boolean,
contentType: ContentType,
startDate: LocalDateTime, startDate: LocalDateTime,
endDate: LocalDateTime, endDate: LocalDateTime,
offset: Long, offset: Long,
@ -938,6 +940,20 @@ class AudioContentQueryRepositoryImpl(
if (!isAdult) { if (!isAdult) {
where = where.and(audioContent.isAdult.isFalse) 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 var select = queryFactory

View File

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

View File

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

View File

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

View File

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

View File

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