Search in sources :

Example 1 with RecoveryFile

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("删除成功");
}
Also used : RecoveryFile(com.qiwenshare.file.domain.RecoveryFile) JwtUser(com.qiwenshare.common.util.security.JwtUser) Operation(io.swagger.v3.oas.annotations.Operation) MyLog(com.qiwenshare.common.anno.MyLog)

Example 2 with RecoveryFile

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("批量删除成功");
}
Also used : RecoveryFile(com.qiwenshare.file.domain.RecoveryFile) JwtUser(com.qiwenshare.common.util.security.JwtUser) Operation(io.swagger.v3.oas.annotations.Operation) MyLog(com.qiwenshare.common.anno.MyLog)

Example 3 with RecoveryFile

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);
}
Also used : LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) UserFile(com.qiwenshare.file.domain.UserFile) RecoveryFile(com.qiwenshare.file.domain.RecoveryFile)

Aggregations

RecoveryFile (com.qiwenshare.file.domain.RecoveryFile)3 MyLog (com.qiwenshare.common.anno.MyLog)2 JwtUser (com.qiwenshare.common.util.security.JwtUser)2 Operation (io.swagger.v3.oas.annotations.Operation)2 LambdaUpdateWrapper (com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper)1 UserFile (com.qiwenshare.file.domain.UserFile)1