|
|
@@ -2,11 +2,15 @@ package com.izouma.nineth.web;
|
|
|
|
|
|
import com.izouma.nineth.service.StatisticService;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import org.springframework.cache.annotation.Cacheable;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.LocalTime;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@RestController
|
|
|
@@ -37,6 +41,17 @@ public class StatisticController {
|
|
|
|
|
|
@GetMapping("/top")
|
|
|
public String top(int year, int month) {
|
|
|
- return statisticService.top(year, month, 50);
|
|
|
+ LocalDateTime start = LocalDateTime.of(year, month, 1, 0, 0, 0);
|
|
|
+ LocalDateTime end = start.plusMonths(1).minusSeconds(1);
|
|
|
+ return statisticService.top(start, end, 50);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/weekTop")
|
|
|
+ @Cacheable("weekTop")
|
|
|
+ public String weekTop() {
|
|
|
+ LocalDate now = LocalDate.now();
|
|
|
+ LocalDate endDate = now.minusDays(now.getDayOfWeek().getValue());
|
|
|
+ LocalDateTime start = LocalDateTime.of(endDate.minusDays(6), LocalTime.MIN);
|
|
|
+ return statisticService.top(start, LocalDateTime.of(endDate, LocalTime.MAX), 50);
|
|
|
}
|
|
|
}
|