| | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | |
| | | tempFileRecord.setExpireTime(LocalDateTime.now().plusHours(2)); // 2小时后过期 |
| | | tempFileRecord.setType(type); |
| | | tempFileMapper.insert(tempFileRecord); |
| | | |
| | | return tempFileRecord; |
| | | } |
| | | |
| | | @Override |
| | | public String uploadByCommon(MultipartFile file, Integer type, Long id) throws IOException{ |
| | | TempFile tempFile = uploadFile(file, type); |
| | | if (tempFile != null) { |
| | | migrateTempFilesToFormal(id, Collections.singletonList(tempFile.getTempId()), type); |
| | | return tempFile.getTempPath(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | } |
| | | |
| | | @Scheduled(cron = "0 0 3 * * ?") // 每天凌晨3点执行 |
| | | // @Scheduled(cron = "0 0 3 * * ?") // 每天凌晨3点执行 |
| | | public void cleanupExpiredTempFiles() { |
| | | LambdaQueryWrapper<TempFile> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.lt(TempFile::getExpireTime, LocalDateTime.now()); // expireTime < 当前时间 |