|
|
@@ -27,33 +27,33 @@ public class FeishuCleanupTask {
|
|
|
/**
|
|
|
* 每天凌晨 2 点执行清理,删除至少 24 小时前创建的文档
|
|
|
*/
|
|
|
- @Scheduled(cron = "0 0 2 * * ?")
|
|
|
- public void deleteFilesBeforeToday() {
|
|
|
- // 计算 24 小时前的时间戳(秒)
|
|
|
- long twentyFourHoursAgo = System.currentTimeMillis() / 1000 - 24 * 60 * 60;
|
|
|
-
|
|
|
- // 获取所有可用 Client 的快照
|
|
|
- List<com.lark.oapi.Client> clients = clientPool.getAllClients();
|
|
|
- for (com.lark.oapi.Client client : clients) {
|
|
|
- try {
|
|
|
- // 分页获取该账号下的所有文档(按创建时间升序)
|
|
|
- List<FeishuFileDTO> allFiles = docApiService.listAllFiles(client);
|
|
|
- for (FeishuFileDTO file : allFiles) {
|
|
|
- long createdTime = Long.parseLong(file.getCreatedTime());
|
|
|
- // 因为升序排列,一旦遇到未满 24 小时的文件,后面的都不会满足条件,可提前退出
|
|
|
- if (createdTime >= twentyFourHoursAgo) {
|
|
|
- break;
|
|
|
- }
|
|
|
- // 跳过 wiki 类型,其他类型删除
|
|
|
- if (!"wiki".equalsIgnoreCase(file.getType())) {
|
|
|
- docApiService.deleteFile(client, file.getToken(), file.getType());
|
|
|
- log.info("已删除: {} | type={} | createdTime={}", file.getName(), file.getType(), file.getCreatedTime());
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("清理飞书文档失败,当前账号将被跳过: {}", e.getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
- log.info("飞书云文档定时清理完成(删除 24 小时前的文档)");
|
|
|
- }
|
|
|
+// @Scheduled(cron = "0 0 2 * * ?")
|
|
|
+// public void deleteFilesBeforeToday() {
|
|
|
+// // 计算 24 小时前的时间戳(秒)
|
|
|
+// long twentyFourHoursAgo = System.currentTimeMillis() / 1000 - 24 * 60 * 60;
|
|
|
+//
|
|
|
+// // 获取所有可用 Client 的快照
|
|
|
+// List<com.lark.oapi.Client> clients = clientPool.getAllClients();
|
|
|
+// for (com.lark.oapi.Client client : clients) {
|
|
|
+// try {
|
|
|
+// // 分页获取该账号下的所有文档(按创建时间升序)
|
|
|
+// List<FeishuFileDTO> allFiles = docApiService.listAllFiles(client);
|
|
|
+// for (FeishuFileDTO file : allFiles) {
|
|
|
+// long createdTime = Long.parseLong(file.getCreatedTime());
|
|
|
+// // 因为升序排列,一旦遇到未满 24 小时的文件,后面的都不会满足条件,可提前退出
|
|
|
+// if (createdTime >= twentyFourHoursAgo) {
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// // 跳过 wiki 类型,其他类型删除
|
|
|
+// if (!"wiki".equalsIgnoreCase(file.getType())) {
|
|
|
+// docApiService.deleteFile(client, file.getToken(), file.getType());
|
|
|
+// log.info("已删除: {} | type={} | createdTime={}", file.getName(), file.getType(), file.getCreatedTime());
|
|
|
+// }
|
|
|
+// }
|
|
|
+// } catch (Exception e) {
|
|
|
+// log.error("清理飞书文档失败,当前账号将被跳过: {}", e.getMessage());
|
|
|
+// }
|
|
|
+// }
|
|
|
+// log.info("飞书云文档定时清理完成(删除 24 小时前的文档)");
|
|
|
+// }
|
|
|
}
|