|
|
@@ -0,0 +1,24 @@
|
|
|
+package cn.iocoder.yudao.module.iscs.config;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
|
|
|
+import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+@EnableScheduling // 启动类上需添加该注解开启定时任务
|
|
|
+@Component
|
|
|
+public class RuleUpdateScheduler {
|
|
|
+
|
|
|
+ private final DynamicRuleManager ruleManager;
|
|
|
+
|
|
|
+ public RuleUpdateScheduler(DynamicRuleManager ruleManager) {
|
|
|
+ this.ruleManager = ruleManager;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 每30秒检查一次(可根据实际需求调整频率)
|
|
|
+ @TenantJob
|
|
|
+ @Scheduled(fixedRate = 600000)
|
|
|
+ public void checkAndUpdateRule() {
|
|
|
+ ruleManager.loadRuleFromDb();
|
|
|
+ }
|
|
|
+}
|