Merge pull request '메인 시리즈 탭 - 완결 시리즈' (#268) from test into main
Reviewed-on: #268
This commit is contained in:
commit
f0b412828a
|
@ -39,15 +39,15 @@ class AudioContentMainTabSeriesController(private val service: AudioContentMainT
|
|||
)
|
||||
}
|
||||
|
||||
@GetMapping("/completed-monthly-rank")
|
||||
fun getRankMonthlyCompletedSeriesList(
|
||||
@GetMapping("/completed-rank")
|
||||
fun getRank10DaysCompletedSeriesList(
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||
pageable: Pageable
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.getRankMonthlyCompletedSeriesList(
|
||||
service.getRank10DaysCompletedSeriesList(
|
||||
memberId = member.id!!,
|
||||
isAdult = member.auth != null,
|
||||
offset = pageable.offset,
|
||||
|
|
|
@ -10,7 +10,9 @@ import kr.co.vividnext.sodalive.member.Member
|
|||
import kr.co.vividnext.sodalive.rank.RankingService
|
||||
import org.springframework.stereotype.Service
|
||||
import java.time.DayOfWeek
|
||||
import java.time.LocalDate
|
||||
import java.time.LocalDateTime
|
||||
import java.time.YearMonth
|
||||
import java.time.temporal.TemporalAdjusters
|
||||
|
||||
@Service
|
||||
|
@ -168,20 +170,13 @@ class AudioContentMainTabSeriesService(
|
|||
return GetSeriesListResponse(totalCount, items)
|
||||
}
|
||||
|
||||
fun getRankMonthlyCompletedSeriesList(
|
||||
fun getRank10DaysCompletedSeriesList(
|
||||
memberId: Long,
|
||||
isAdult: Boolean,
|
||||
offset: Long,
|
||||
limit: Long
|
||||
): GetSeriesListResponse {
|
||||
val monthlyRankingStartDate = LocalDateTime.now()
|
||||
.withDayOfMonth(1)
|
||||
.withHour(15)
|
||||
.withMinute(0)
|
||||
.withSecond(0)
|
||||
.minusDays(1)
|
||||
val monthlyRankingEndDate = monthlyRankingStartDate
|
||||
.plusMonths(1)
|
||||
val (startDate, endDate) = calculateStartAndEndDate()
|
||||
|
||||
val totalCount = rankingService.getCompleteSeriesRankingTotalCount(
|
||||
memberId = memberId,
|
||||
|
@ -191,8 +186,8 @@ class AudioContentMainTabSeriesService(
|
|||
val items = rankingService.getCompleteSeriesRanking(
|
||||
memberId = memberId,
|
||||
isAdult = isAdult,
|
||||
startDate = monthlyRankingStartDate,
|
||||
endDate = monthlyRankingEndDate,
|
||||
startDate = startDate,
|
||||
endDate = endDate,
|
||||
offset = offset,
|
||||
limit = limit
|
||||
)
|
||||
|
@ -218,4 +213,30 @@ class AudioContentMainTabSeriesService(
|
|||
isAdult = isAdult
|
||||
)
|
||||
}
|
||||
|
||||
private fun calculateStartAndEndDate(today: LocalDate = LocalDate.now()): Pair<LocalDateTime, LocalDateTime> {
|
||||
val yearMonth = YearMonth.from(today)
|
||||
val lastDayOfMonth = yearMonth.lengthOfMonth()
|
||||
|
||||
return when (today.dayOfMonth) {
|
||||
in 11..20 -> Pair(
|
||||
today.withDayOfMonth(1).minusDays(1).atTime(15, 0),
|
||||
today.withDayOfMonth(10).atTime(15, 0)
|
||||
)
|
||||
|
||||
in 21..lastDayOfMonth -> Pair(
|
||||
today.withDayOfMonth(10).atTime(15, 0),
|
||||
today.withDayOfMonth(20).atTime(15, 0)
|
||||
)
|
||||
|
||||
else -> {
|
||||
val previousMonth = yearMonth.minusMonths(1)
|
||||
val lastDayOfPreviousMonth = previousMonth.lengthOfMonth()
|
||||
Pair(
|
||||
LocalDate.of(previousMonth.year, previousMonth.month, 20).atTime(15, 0),
|
||||
LocalDate.of(previousMonth.year, previousMonth.month, lastDayOfPreviousMonth).atTime(15, 0)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue