|
|
@@ -0,0 +1,33 @@
|
|
|
+package com.fs.task;
|
|
|
+
|
|
|
+import com.fs.feishu.service.IFsAuthLinkTokenService;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 飞书授权链接token清理定时任务
|
|
|
+ * 每天凌晨3点清理 fs_auth_link_token 表中已过期的记录
|
|
|
+ */
|
|
|
+@Component("authLinkTokenCleanTask")
|
|
|
+@Slf4j
|
|
|
+public class AuthLinkTokenCleanTask {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IFsAuthLinkTokenService authLinkTokenService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 每天凌晨3点执行,清理已过期的token记录
|
|
|
+ */
|
|
|
+// @Scheduled(cron = "0 0 3 * * ?")
|
|
|
+ public void cleanExpiredTokens() {
|
|
|
+ try {
|
|
|
+ log.info("授权token清理 - 定时任务开始");
|
|
|
+ int count = authLinkTokenService.cleanExpiredTokens();
|
|
|
+ log.info("授权token清理 - 定时任务完成 | 删除过期记录={}", count);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("授权token清理 - 定时任务执行失败", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|