xiangpei
2024-11-13 37e189c3e7f8ae4468afbfd1abf9a83d4128a627
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/sync/deleteSync.java
@@ -25,7 +25,7 @@
    }
    @Scheduled(cron = "0 */10 * * * ?")
//    @Scheduled(cron = "0 */10 * * * ?")
    public void remove() throws IOException {
        System.out.println("同步删除......");
        List<Long> ids = baseMapper.getWillDeleted(LocalDateTime.now().minusDays(1));
@@ -34,9 +34,24 @@
            return;
        }
        for (Long ossId : ids) {
            baseMapper.deleteById(ossId);
            HttpUtils.sendDeleteRequest(boundary.getVideo() + "/resource/synchronization/delete",
                String.valueOf(ossId));
        }
    }
    /**
     * 每小时删除30天之前的文件信息,确保上面的定时任务不会因为停电关机等原因导致文件未被删除
     *
     * @throws IOException
     */
//    @Scheduled(cron = "0 0 * * * ?")
    public void removeOssTable() throws IOException {
        System.out.println("每小时定时删除超过30天的数据库文件信息......");
        List<Long> ids = baseMapper.getWillDeleted(LocalDateTime.now().minusDays(30));
        if (ids.size() == 0) {
            return;
        }
        baseMapper.deleteBatchIds(ids);
    }
}