Przeglądaj źródła

添加手动初始化redis的数据值

wutt 5 lat temu
rodzic
commit
44b60d181d

+ 7 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ImageProcessingController.java

@@ -3,6 +3,8 @@ package com.management.platform.controller;
 import com.management.platform.entity.vo.ScreenshotVO;
 import com.management.platform.service.ScreenshotService;
 import com.management.platform.util.HttpRespMsg;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import javax.annotation.Resource;
@@ -15,6 +17,7 @@ import javax.annotation.Resource;
  */
 @RestController
 @RequestMapping("/imageProcessing")
+@EnableScheduling
 public class ImageProcessingController {
 
     @Resource
@@ -31,9 +34,12 @@ public class ImageProcessingController {
     }
 
     /**
-     * 初始化redis图片搜索的关键词
+     * 初始化redis图片搜索的关键词,
+     * 防止数据库初始添加了其他字段导致redis里的数据不是最新的,
+     * 做定时在系统不忙时进行更新redis里的最新图片关键词(注意:如果想要立即更新可手动调用)
      */
     @RequestMapping("/updateKeyWords")
+    @Scheduled(cron = "0 0 23 * * ?")//配置时间点触发(每日23点)
     public HttpRespMsg updateRedisPicContentKeywords() {
         return screenshotService.updateRedisPicContentKeywords();
     }