|
@@ -0,0 +1,29 @@
|
|
|
|
|
+package com.etotem.num.service;
|
|
|
|
|
+
|
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 系统定时任务容器。
|
|
|
|
|
+ * 集中管理所有 @Scheduled 任务,避免分散在多个 Service 中难以维护。
|
|
|
|
|
+ */
|
|
|
|
|
+@Component
|
|
|
|
|
+public class ScheduledTasks {
|
|
|
|
|
+
|
|
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(ScheduledTasks.class);
|
|
|
|
|
+
|
|
|
|
|
+ private final QuotaService quotaService;
|
|
|
|
|
+
|
|
|
|
|
+ public ScheduledTasks(QuotaService quotaService) { this.quotaService = quotaService; }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 每日 00:00 重置所有用户咨询配额(chat_count_today = 0)。
|
|
|
|
|
+ */
|
|
|
|
|
+ @Scheduled(cron = "0 0 0 * * ?")
|
|
|
|
|
+ public void resetDailyQuota() {
|
|
|
|
|
+ int affected = quotaService.resetDailyQuota();
|
|
|
|
|
+ log.info("[Scheduled] 每日配额重置完成,影响 {} 条记录", affected);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|