use of com.qiwenshare.file.domain.RecoveryFile in project qiwen-file by qiwenshare.
the class RecoveryFileController method deleteRecoveryFile.
@Operation(summary = "删除回收文件", description = "删除回收文件", tags = { "recoveryfile" })
@MyLog(operation = "删除回收文件", module = CURRENT_MODULE)
@RequestMapping(value = "/deleterecoveryfile", method = RequestMethod.POST)
@ResponseBody
public RestResult<String> deleteRecoveryFile(@RequestBody DeleteRecoveryFileDTO deleteRecoveryFileDTO) {
JwtUser sessionUserBean = SessionUtil.getSession();
RecoveryFile recoveryFile = recoveryFileService.getById(deleteRecoveryFileDTO.getRecoveryFileId());
asyncTaskComp.deleteUserFile(recoveryFile.getUserFileId());
recoveryFileService.removeById(deleteRecoveryFileDTO.getRecoveryFileId());
return RestResult.success().data("删除成功");
}
use of com.qiwenshare.file.domain.RecoveryFile in project qiwen-file by qiwenshare.
the class RecoveryFileController method batchDeleteRecoveryFile.
@Operation(summary = "批量删除回收文件", description = "批量删除回收文件", tags = { "recoveryfile" })
@RequestMapping(value = "/batchdelete", method = RequestMethod.POST)
@MyLog(operation = "批量删除回收文件", module = CURRENT_MODULE)
@ResponseBody
public RestResult<String> batchDeleteRecoveryFile(@RequestBody BatchDeleteRecoveryFileDTO batchDeleteRecoveryFileDTO) {
JwtUser sessionUserBean = SessionUtil.getSession();
List<RecoveryFile> recoveryFileList = JSON.parseArray(batchDeleteRecoveryFileDTO.getRecoveryFileIds(), RecoveryFile.class);
for (RecoveryFile recoveryFile : recoveryFileList) {
RecoveryFile recoveryFile1 = recoveryFileService.getById(recoveryFile.getRecoveryFileId());
asyncTaskComp.deleteUserFile(recoveryFile1.getUserFileId());
recoveryFileService.removeById(recoveryFile1.getRecoveryFileId());
}
return RestResult.success().data("批量删除成功");
}
use of com.qiwenshare.file.domain.RecoveryFile in project qiwen-file by qiwenshare.
the class UserFileService method deleteUserFile.
@Override
public void deleteUserFile(Long userFileId, Long sessionUserId) {
UserFile userFile = userFileMapper.selectById(userFileId);
String uuid = UUID.randomUUID().toString();
if (userFile.getIsDir() == 1) {
LambdaUpdateWrapper<UserFile> userFileLambdaUpdateWrapper = new LambdaUpdateWrapper<UserFile>();
userFileLambdaUpdateWrapper.set(UserFile::getDeleteFlag, RandomUtil.randomInt(FileConstant.deleteFileRandomSize)).set(UserFile::getDeleteBatchNum, uuid).set(UserFile::getDeleteTime, DateUtil.getCurrentTime()).eq(UserFile::getUserFileId, userFileId);
userFileMapper.update(null, userFileLambdaUpdateWrapper);
String filePath = userFile.getFilePath() + userFile.getFileName() + "/";
updateFileDeleteStateByFilePath(filePath, uuid, sessionUserId);
} else {
UserFile userFileTemp = userFileMapper.selectById(userFileId);
LambdaUpdateWrapper<UserFile> userFileLambdaUpdateWrapper = new LambdaUpdateWrapper<>();
userFileLambdaUpdateWrapper.set(UserFile::getDeleteFlag, RandomUtil.randomInt(1, FileConstant.deleteFileRandomSize)).set(UserFile::getDeleteTime, DateUtil.getCurrentTime()).set(UserFile::getDeleteBatchNum, uuid).eq(UserFile::getUserFileId, userFileTemp.getUserFileId());
userFileMapper.update(null, userFileLambdaUpdateWrapper);
}
RecoveryFile recoveryFile = new RecoveryFile();
recoveryFile.setUserFileId(userFileId);
recoveryFile.setDeleteTime(DateUtil.getCurrentTime());
recoveryFile.setDeleteBatchNum(uuid);
recoveryFileMapper.insert(recoveryFile);
}
Aggregations