Эх сурвалжийг харах

固定周日更新排行榜

licailing 3 жил өмнө
parent
commit
52ee30bc74

+ 6 - 0
src/main/java/com/izouma/nineth/service/CacheService.java

@@ -112,4 +112,10 @@ public class CacheService {
     @CacheEvict(value = "news", key = "#id")
     public void clearNews(Long id) {
     }
+
+    @Scheduled(cron = "0 0 0 * * ?")
+    @CacheEvict(value = "fixedTop", allEntries = true)
+    public void clearFixedTop() {
+    }
+
 }

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

@@ -103,4 +103,11 @@ public class StatisticController {
     public void clearUser() {
         cacheService.clearUser();
     }
+
+    @GetMapping("/fixedTop")
+    @Cacheable("fixedTop")
+    public String fixedTop() {
+        LocalDateTime start = LocalDateTime.of(2022, 5, 30, 20, 0, 0);
+        return statisticService.top(start, LocalDateTime.now(), 50);
+    }
 }