Search in sources :

Example 1 with UploadFileVo

use of com.qiwenshare.file.vo.file.UploadFileVo in project qiwen-file by qiwenshare.

the class FiletransferController method uploadFile.

@Operation(summary = "上传文件", description = "真正的上传文件接口", tags = { "filetransfer" })
@RequestMapping(value = "/uploadfile", method = RequestMethod.POST)
@MyLog(operation = "上传文件", module = CURRENT_MODULE)
@ResponseBody
public RestResult<UploadFileVo> uploadFile(HttpServletRequest request, UploadFileDTO uploadFileDto) {
    JwtUser sessionUserBean = SessionUtil.getSession();
    filetransferService.uploadFile(request, uploadFileDto, sessionUserBean.getUserId());
    UploadFileVo uploadFileVo = new UploadFileVo();
    return RestResult.success().data(uploadFileVo);
}
Also used : UploadFileVo(com.qiwenshare.file.vo.file.UploadFileVo) JwtUser(com.qiwenshare.common.util.security.JwtUser) Operation(io.swagger.v3.oas.annotations.Operation) MyLog(com.qiwenshare.common.anno.MyLog)

Example 2 with UploadFileVo

use of com.qiwenshare.file.vo.file.UploadFileVo in project qiwen-file by qiwenshare.

the class FiletransferController method uploadFileSpeed.

@Operation(summary = "极速上传", description = "校验文件MD5判断文件是否存在,如果存在直接上传成功并返回skipUpload=true,如果不存在返回skipUpload=false需要再次调用该接口的POST方法", tags = { "filetransfer" })
@RequestMapping(value = "/uploadfile", method = RequestMethod.GET)
@MyLog(operation = "极速上传", module = CURRENT_MODULE)
@ResponseBody
public RestResult<UploadFileVo> uploadFileSpeed(UploadFileDTO uploadFileDto) {
    JwtUser sessionUserBean = SessionUtil.getSession();
    boolean isCheckSuccess = storageService.checkStorage(sessionUserBean.getUserId(), uploadFileDto.getTotalSize());
    if (!isCheckSuccess) {
        return RestResult.fail().message("存储空间不足");
    }
    UploadFileVo uploadFileVo = filetransferService.uploadFileSpeed(uploadFileDto);
    return RestResult.success().data(uploadFileVo);
}
Also used : UploadFileVo(com.qiwenshare.file.vo.file.UploadFileVo) JwtUser(com.qiwenshare.common.util.security.JwtUser) Operation(io.swagger.v3.oas.annotations.Operation) MyLog(com.qiwenshare.common.anno.MyLog)

Example 3 with UploadFileVo

use of com.qiwenshare.file.vo.file.UploadFileVo in project qiwen-file by qiwenshare.

the class FiletransferService method uploadFileSpeed.

@Override
public UploadFileVo uploadFileSpeed(UploadFileDTO uploadFileDTO) {
    UploadFileVo uploadFileVo = new UploadFileVo();
    JwtUser sessionUserBean = SessionUtil.getSession();
    Map<String, Object> param = new HashMap<>();
    param.put("identifier", uploadFileDTO.getIdentifier());
    List<FileBean> list = fileMapper.selectByMap(param);
    if (list != null && !list.isEmpty()) {
        FileBean file = list.get(0);
        UserFile userFile = new UserFile();
        userFile.setUserId(sessionUserBean.getUserId());
        String relativePath = uploadFileDTO.getRelativePath();
        if (relativePath.contains("/")) {
            userFile.setFilePath(uploadFileDTO.getFilePath() + UFOPUtils.getParentPath(relativePath) + "/");
            fileDealComp.restoreParentFilePath(uploadFileDTO.getFilePath() + UFOPUtils.getParentPath(relativePath) + "/", sessionUserBean.getUserId());
            fileDealComp.deleteRepeatSubDirFile(uploadFileDTO.getFilePath(), sessionUserBean.getUserId());
        } else {
            userFile.setFilePath(uploadFileDTO.getFilePath());
        }
        String fileName = uploadFileDTO.getFilename();
        userFile.setFileName(UFOPUtils.getFileNameNotExtend(fileName));
        userFile.setExtendName(UFOPUtils.getFileExtendName(fileName));
        userFile.setDeleteFlag(0);
        List<UserFile> userFileList = userFileMapper.selectList(new QueryWrapper<>(userFile));
        if (userFileList.size() <= 0) {
            userFile.setIsDir(0);
            userFile.setUploadTime(DateUtil.getCurrentTime());
            userFile.setFileId(file.getFileId());
            userFileMapper.insert(userFile);
            fileDealComp.uploadESByUserFileId(userFile.getUserFileId());
        }
        uploadFileVo.setSkipUpload(true);
    } else {
        uploadFileVo.setSkipUpload(false);
        List<Integer> uploaded = uploadTaskDetailMapper.selectUploadedChunkNumList(uploadFileDTO.getIdentifier());
        if (uploaded != null && !uploaded.isEmpty()) {
            uploadFileVo.setUploaded(uploaded);
        } else {
            LambdaQueryWrapper<UploadTask> lambdaQueryWrapper = new LambdaQueryWrapper<>();
            lambdaQueryWrapper.eq(UploadTask::getIdentifier, uploadFileDTO.getIdentifier());
            List<UploadTask> rslist = uploadTaskMapper.selectList(lambdaQueryWrapper);
            if (rslist == null || rslist.isEmpty()) {
                UploadTask uploadTask = new UploadTask();
                uploadTask.setIdentifier(uploadFileDTO.getIdentifier());
                uploadTask.setUploadTime(DateUtil.getCurrentTime());
                uploadTask.setUploadStatus(UploadFileStatusEnum.UNCOMPLATE.getCode());
                uploadTask.setFileName(uploadFileDTO.getFilename());
                String relativePath = uploadFileDTO.getRelativePath();
                if (relativePath.contains("/")) {
                    uploadTask.setFilePath(uploadFileDTO.getFilePath() + UFOPUtils.getParentPath(relativePath) + "/");
                } else {
                    uploadTask.setFilePath(uploadFileDTO.getFilePath());
                }
                uploadTask.setExtendName(uploadTask.getExtendName());
                uploadTask.setUserId(sessionUserBean.getUserId());
                uploadTaskMapper.insert(uploadTask);
            }
        }
    }
    return uploadFileVo;
}
Also used : LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) UploadFileVo(com.qiwenshare.file.vo.file.UploadFileVo) JwtUser(com.qiwenshare.common.util.security.JwtUser)

Aggregations

JwtUser (com.qiwenshare.common.util.security.JwtUser)3 UploadFileVo (com.qiwenshare.file.vo.file.UploadFileVo)3 MyLog (com.qiwenshare.common.anno.MyLog)2 Operation (io.swagger.v3.oas.annotations.Operation)2 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)1