Commit f858aa22 authored by wanglong's avatar wanglong

每天定时删除二维码图片

parent e9a47264
package com.yeejoin.amos.boot.module.ugp.api.quartz;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import java.io.File;
@Component
@EnableScheduling
public class CylinderSchedulerJob {
/**
* 每天3点-删除图片
*/
@Scheduled(cron = "${cylinder-early-warning-cron:0 0 3 * * ?}")
public void clean() {
dayReport(new File(new File("/home/yeejoin/ugp/minio-data/upload/common/ugp/qrcode").getAbsolutePath()));
}
public static void dayReport(File file) {
// file.isAbsolute();
if (!ValidationUtil.isEmpty(file.listFiles())) {
for (File f : file.listFiles()) {
//实现递归
if (f.isDirectory()) {
dayReport(f);
}
//清理文件
f.delete();
System.out.println(f.getName() + "已清理!!!");
}
}
}
// public static void main(String[] args) {
//
// dayReport(new File(new File("/home/yeejoin/ugp/minio-data/upload/common/ugp/qrcode").getAbsolutePath()));
// }
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment