메인 시리즈 탭 - 완결 시리즈 #268
@@ -39,15 +39,15 @@ class AudioContentMainTabSeriesController(private val service: AudioContentMainT
 | 
				
			|||||||
        )
 | 
					        )
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @GetMapping("/completed-monthly-rank")
 | 
					    @GetMapping("/completed-rank")
 | 
				
			||||||
    fun getRankMonthlyCompletedSeriesList(
 | 
					    fun getRank10DaysCompletedSeriesList(
 | 
				
			||||||
        @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
 | 
					        @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
 | 
				
			||||||
        pageable: Pageable
 | 
					        pageable: Pageable
 | 
				
			||||||
    ) = run {
 | 
					    ) = run {
 | 
				
			||||||
        if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
 | 
					        if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ApiResponse.ok(
 | 
					        ApiResponse.ok(
 | 
				
			||||||
            service.getRankMonthlyCompletedSeriesList(
 | 
					            service.getRank10DaysCompletedSeriesList(
 | 
				
			||||||
                memberId = member.id!!,
 | 
					                memberId = member.id!!,
 | 
				
			||||||
                isAdult = member.auth != null,
 | 
					                isAdult = member.auth != null,
 | 
				
			||||||
                offset = pageable.offset,
 | 
					                offset = pageable.offset,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,7 +10,9 @@ import kr.co.vividnext.sodalive.member.Member
 | 
				
			|||||||
import kr.co.vividnext.sodalive.rank.RankingService
 | 
					import kr.co.vividnext.sodalive.rank.RankingService
 | 
				
			||||||
import org.springframework.stereotype.Service
 | 
					import org.springframework.stereotype.Service
 | 
				
			||||||
import java.time.DayOfWeek
 | 
					import java.time.DayOfWeek
 | 
				
			||||||
 | 
					import java.time.LocalDate
 | 
				
			||||||
import java.time.LocalDateTime
 | 
					import java.time.LocalDateTime
 | 
				
			||||||
 | 
					import java.time.YearMonth
 | 
				
			||||||
import java.time.temporal.TemporalAdjusters
 | 
					import java.time.temporal.TemporalAdjusters
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@Service
 | 
					@Service
 | 
				
			||||||
@@ -168,20 +170,13 @@ class AudioContentMainTabSeriesService(
 | 
				
			|||||||
        return GetSeriesListResponse(totalCount, items)
 | 
					        return GetSeriesListResponse(totalCount, items)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fun getRankMonthlyCompletedSeriesList(
 | 
					    fun getRank10DaysCompletedSeriesList(
 | 
				
			||||||
        memberId: Long,
 | 
					        memberId: Long,
 | 
				
			||||||
        isAdult: Boolean,
 | 
					        isAdult: Boolean,
 | 
				
			||||||
        offset: Long,
 | 
					        offset: Long,
 | 
				
			||||||
        limit: Long
 | 
					        limit: Long
 | 
				
			||||||
    ): GetSeriesListResponse {
 | 
					    ): GetSeriesListResponse {
 | 
				
			||||||
        val monthlyRankingStartDate = LocalDateTime.now()
 | 
					        val (startDate, endDate) = calculateStartAndEndDate()
 | 
				
			||||||
            .withDayOfMonth(1)
 | 
					 | 
				
			||||||
            .withHour(15)
 | 
					 | 
				
			||||||
            .withMinute(0)
 | 
					 | 
				
			||||||
            .withSecond(0)
 | 
					 | 
				
			||||||
            .minusDays(1)
 | 
					 | 
				
			||||||
        val monthlyRankingEndDate = monthlyRankingStartDate
 | 
					 | 
				
			||||||
            .plusMonths(1)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        val totalCount = rankingService.getCompleteSeriesRankingTotalCount(
 | 
					        val totalCount = rankingService.getCompleteSeriesRankingTotalCount(
 | 
				
			||||||
            memberId = memberId,
 | 
					            memberId = memberId,
 | 
				
			||||||
@@ -191,8 +186,8 @@ class AudioContentMainTabSeriesService(
 | 
				
			|||||||
        val items = rankingService.getCompleteSeriesRanking(
 | 
					        val items = rankingService.getCompleteSeriesRanking(
 | 
				
			||||||
            memberId = memberId,
 | 
					            memberId = memberId,
 | 
				
			||||||
            isAdult = isAdult,
 | 
					            isAdult = isAdult,
 | 
				
			||||||
            startDate = monthlyRankingStartDate,
 | 
					            startDate = startDate,
 | 
				
			||||||
            endDate = monthlyRankingEndDate,
 | 
					            endDate = endDate,
 | 
				
			||||||
            offset = offset,
 | 
					            offset = offset,
 | 
				
			||||||
            limit = limit
 | 
					            limit = limit
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
@@ -218,4 +213,30 @@ class AudioContentMainTabSeriesService(
 | 
				
			|||||||
            isAdult = isAdult
 | 
					            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)
 | 
				
			||||||
 | 
					                )
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user