콘텐츠 랭킹 데이터 전체보기 API - 페이징 추가

This commit is contained in:
Klaus 2023-10-15 03:38:26 +09:00
parent 9146e2e231
commit 149a3ad2f1
3 changed files with 18 additions and 4 deletions

View File

@ -151,10 +151,17 @@ class AudioContentController(private val service: AudioContentService) {
@GetMapping("/ranking") @GetMapping("/ranking")
fun getAudioContentRanking( fun getAudioContentRanking(
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member? @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
pageable: Pageable
) = run { ) = run {
if (member == null) throw SodaException("로그인 정보를 확인해주세요.") if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
ApiResponse.ok(service.getAudioContentRanking(member = member)) ApiResponse.ok(
service.getAudioContentRanking(
member = member,
offset = pageable.offset,
limit = pageable.pageSize.toLong()
)
)
} }
} }

View File

@ -88,6 +88,7 @@ interface AudioContentQueryRepository {
isAdult: Boolean, isAdult: Boolean,
startDate: LocalDateTime, startDate: LocalDateTime,
endDate: LocalDateTime, endDate: LocalDateTime,
offset: Long = 0,
limit: Long = 12 limit: Long = 12
): List<GetAudioContentRankingItem> ): List<GetAudioContentRankingItem>
} }
@ -442,6 +443,7 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
isAdult: Boolean, isAdult: Boolean,
startDate: LocalDateTime, startDate: LocalDateTime,
endDate: LocalDateTime, endDate: LocalDateTime,
offset: Long,
limit: Long limit: Long
): List<GetAudioContentRankingItem> { ): List<GetAudioContentRankingItem> {
var where = audioContent.isActive.isTrue var where = audioContent.isActive.isTrue

View File

@ -577,7 +577,11 @@ class AudioContentService(
} }
} }
fun getAudioContentRanking(member: Member): GetAudioContentRanking { fun getAudioContentRanking(
member: Member,
offset: Long,
limit: Long
): GetAudioContentRanking {
val currentDateTime = LocalDateTime.now() val currentDateTime = LocalDateTime.now()
val startDate = currentDateTime val startDate = currentDateTime
.withHour(15) .withHour(15)
@ -597,7 +601,8 @@ class AudioContentService(
startDate = startDate, startDate = startDate,
endDate = endDate, endDate = endDate,
isAdult = member.auth != null, isAdult = member.auth != null,
limit = 50 offset = offset,
limit = limit
) )
return GetAudioContentRanking( return GetAudioContentRanking(