콘텐츠 메인 - 순위 정렬(매출, 후원, 댓글, 좋아요) 추가

This commit is contained in:
2023-11-02 02:28:23 +09:00
parent c6c9073fa0
commit d45a34525b
7 changed files with 137 additions and 66 deletions

View File

@@ -19,6 +19,9 @@ import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RequestPart
import org.springframework.web.bind.annotation.RestController
import org.springframework.web.multipart.MultipartFile
import java.time.DayOfWeek
import java.time.LocalDateTime
import java.time.temporal.TemporalAdjusters
@RestController
@RequestMapping("/audio-content")
@@ -152,15 +155,29 @@ class AudioContentController(private val service: AudioContentService) {
@GetMapping("/ranking")
fun getAudioContentRanking(
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
@RequestParam("sortType") sortType: String,
pageable: Pageable
) = run {
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
val currentDateTime = LocalDateTime.now()
val startDate = currentDateTime
.withHour(15)
.withMinute(0)
.withSecond(0)
.minusWeeks(1)
.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY))
val endDate = startDate
.plusDays(7)
ApiResponse.ok(
service.getAudioContentRanking(
member = member,
isAdult = member.auth != null,
startDate = startDate,
endDate = endDate,
offset = pageable.offset,
limit = pageable.pageSize.toLong()
limit = pageable.pageSize.toLong(),
sortType = sortType
)
)
}