Quellcode durchsuchen

统计页缓存

wangqifan vor 3 Jahren
Ursprung
Commit
1f68b8b2d0

+ 4 - 2
src/main/java/com/izouma/nineth/service/StatisticService.java

@@ -85,11 +85,13 @@ public class StatisticService {
     /*
     按月
      */
-    public Long userTrendV2(String yearMonth) {
+    public Map<String, Long> userTrendV2(String yearMonth) {
+        Map<String, Long> map = new HashMap<>();
         YearMonth month = YearMonth.parse(yearMonth);
         LocalDateTime end = month.atEndOfMonth().atTime(LocalTime.MAX);
         LocalDateTime start = month.atDay(1).atStartOfDay();
-        return userRepo.countByCreatedAtBetween(start, end);
+        map.put(yearMonth, userRepo.countByCreatedAtBetween(start, end));
+        return map;
     }
 
     public Map<String, Map<String, Long>> orderNumTrend(int day, Long userId) {

+ 1 - 1
src/main/java/com/izouma/nineth/web/StatisticController.java

@@ -43,7 +43,7 @@ public class StatisticController {
     @GetMapping("/userTrendV2")
     @Cacheable(value = "userTrendV2", key = "#yearMonth")
     @PreAuthorize("hasAnyRole('ADMIN','ORDERINFO')")
-    public Long userTrendV2(String yearMonth) {
+    public Map<String, Long> userTrendV2(String yearMonth) {
         return statisticService.userTrendV2(yearMonth);
     }