kongzy
2024-07-05 14821e28286d773ad5ff2c13510e39c5eb117daf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package com.gkhy.exam.framework.job;
 
import cn.hutool.core.io.FileUtil;
import com.gkhy.exam.common.config.FilePathConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
 
import java.io.File;
 
/**
 * 清空上传目录
 */
@Component
public class RemoveUploadJob {
    @Autowired
    private FilePathConfig filePathConfig;
 
    /**
     * 每天23点执行
     */
    @Scheduled(cron = "0 0 23 * * ?")
    public void progress(){
        FileUtil.del(new File(filePathConfig.getBasePath()));
        FileUtil.del(new File(filePathConfig.getTempPath()));
        FileUtil.del(new File(filePathConfig.getBigPath()));
    }
}