diff --git a/src/main/java/com/flab/offcoupon/dto/response/MonthlyOrderStatistics.java b/src/main/java/com/flab/offcoupon/dto/response/MonthlyOrderStatistics.java index ef42e5b..032e56f 100644 --- a/src/main/java/com/flab/offcoupon/dto/response/MonthlyOrderStatistics.java +++ b/src/main/java/com/flab/offcoupon/dto/response/MonthlyOrderStatistics.java @@ -19,10 +19,10 @@ public final class MonthlyOrderStatistics { private final BigDecimal totalCouponPrice; public MonthlyOrderStatistics(MonthlyOrderStatisticsVo vo) { - this.yearMonth = (vo != null) ? vo.yearMonth() : null; - this.totalOrderCnt = (vo != null) ? vo.totalOrderCnt() : 0; - this.totalPaymentPrice = (vo != null) ? vo.totalPaymentPrice() : BigDecimal.ZERO; - this.totalCouponUseCnt = (vo != null) ? vo.totalCouponUseCnt() : 0; - this.totalCouponPrice = (vo != null) ? vo.totalCouponPrice() : BigDecimal.ZERO; + this.yearMonth = vo.yearMonth(); + this.totalOrderCnt = vo.totalOrderCnt(); + this.totalPaymentPrice = vo.totalPaymentPrice(); + this.totalCouponUseCnt = vo.totalCouponUseCnt(); + this.totalCouponPrice = vo.totalCouponPrice(); } } diff --git a/src/main/java/com/flab/offcoupon/service/StatisticsService.java b/src/main/java/com/flab/offcoupon/service/StatisticsService.java index 522d07c..3d972ec 100644 --- a/src/main/java/com/flab/offcoupon/service/StatisticsService.java +++ b/src/main/java/com/flab/offcoupon/service/StatisticsService.java @@ -43,9 +43,10 @@ public ResponseDTO> getMonthlyOrderStatistics(Stati List monthlyStatisticsList = getMonthlyStatistics(startedAt, endedAt); // 월별로 정렬 - monthlyStatisticsList.sort(Comparator.comparing(MonthlyOrderStatistics::getYearMonth)); - - return ResponseDTO.getSuccessResult(monthlyStatisticsList); + return ResponseDTO.getSuccessResult(monthlyStatisticsList + .stream() + .sorted(Comparator.comparing(MonthlyOrderStatistics::getYearMonth)) + .toList()); } /** @@ -98,8 +99,9 @@ private List getMonthlyStatistics(LocalDate startedAt, L /** * 현재 월과 대상 날짜가 같은지 확인하는 메서드입니다. + * * @param currentYearMonth 현재 월 - * @param target 대상 날짜 + * @param target 대상 날짜 * @return 현재 월과 대상 날짜가 같은지 여부 */ private boolean isSameYearMonth(YearMonth currentYearMonth, LocalDate target) { @@ -109,8 +111,9 @@ private boolean isSameYearMonth(YearMonth currentYearMonth, LocalDate target) { /** * 시작일부터 종료일까지의 월 차이를 계산하는 메서드입니다. * 병렬 스트림에서 사용하기 위해 long 타입으로 반환합니다. + * * @param startedAt 시작일 - * @param endedAt 종료일 + * @param endedAt 종료일 * @return 시작일부터 종료일까지의 월 차이 */ private long countMonthDifference(LocalDate startedAt, LocalDate endedAt) { diff --git a/src/main/resources/mapper/StatisticsMapper.xml b/src/main/resources/mapper/StatisticsMapper.xml index 154f73d..388fc88 100644 --- a/src/main/resources/mapper/StatisticsMapper.xml +++ b/src/main/resources/mapper/StatisticsMapper.xml @@ -5,15 +5,15 @@ \ No newline at end of file