Search in sources :

Example 6 with JwtUser

use of com.qiwenshare.common.util.security.JwtUser in project qiwen-file by qiwenshare.

the class FileController method moveFile.

@Operation(summary = "文件移动", description = "可以移动文件或者目录", tags = { "file" })
@RequestMapping(value = "/movefile", method = RequestMethod.POST)
@MyLog(operation = "文件移动", module = CURRENT_MODULE)
@ResponseBody
public RestResult<String> moveFile(@RequestBody MoveFileDTO moveFileDto) {
    JwtUser sessionUserBean = SessionUtil.getSession();
    String oldfilePath = moveFileDto.getOldFilePath();
    String newfilePath = moveFileDto.getFilePath();
    String fileName = moveFileDto.getFileName();
    String extendName = moveFileDto.getExtendName();
    if (StringUtil.isEmpty(extendName)) {
        String testFilePath = oldfilePath + fileName + "/";
        if (newfilePath.startsWith(testFilePath)) {
            return RestResult.fail().message("原路径与目标路径冲突,不能移动");
        }
    }
    userFileService.updateFilepathByFilepath(oldfilePath, newfilePath, fileName, extendName, sessionUserBean.getUserId());
    return RestResult.success();
}
Also used : JwtUser(com.qiwenshare.common.util.security.JwtUser) Operation(io.swagger.v3.oas.annotations.Operation) MyLog(com.qiwenshare.common.anno.MyLog)

Example 7 with JwtUser

use of com.qiwenshare.common.util.security.JwtUser in project qiwen-file by qiwenshare.

the class FileController method renameFile.

@Operation(summary = "文件重命名", description = "文件重命名", tags = { "file" })
@RequestMapping(value = "/renamefile", method = RequestMethod.POST)
@MyLog(operation = "文件重命名", module = CURRENT_MODULE)
@ResponseBody
public RestResult<String> renameFile(@RequestBody RenameFileDTO renameFileDto) {
    JwtUser sessionUserBean = SessionUtil.getSession();
    UserFile userFile = userFileService.getById(renameFileDto.getUserFileId());
    List<UserFile> userFiles = userFileService.selectUserFileByNameAndPath(renameFileDto.getFileName(), userFile.getFilePath(), sessionUserBean.getUserId());
    if (userFiles != null && !userFiles.isEmpty()) {
        return RestResult.fail().message("同名文件已存在");
    }
    LambdaUpdateWrapper<UserFile> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
    lambdaUpdateWrapper.set(UserFile::getFileName, renameFileDto.getFileName()).set(UserFile::getUploadTime, DateUtil.getCurrentTime()).eq(UserFile::getUserFileId, renameFileDto.getUserFileId());
    userFileService.update(lambdaUpdateWrapper);
    if (1 == userFile.getIsDir()) {
        List<UserFile> list = userFileService.selectFileListLikeRightFilePath(userFile.getFilePath() + userFile.getFileName() + "/", sessionUserBean.getUserId());
        for (UserFile newUserFile : list) {
            newUserFile.setFilePath(newUserFile.getFilePath().replaceFirst(userFile.getFilePath() + userFile.getFileName() + "/", userFile.getFilePath() + renameFileDto.getFileName() + "/"));
            userFileService.updateById(newUserFile);
        }
    }
    fileDealComp.uploadESByUserFileId(renameFileDto.getUserFileId());
    return RestResult.success();
}
Also used : LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) UserFile(com.qiwenshare.file.domain.UserFile) JwtUser(com.qiwenshare.common.util.security.JwtUser) Operation(io.swagger.v3.oas.annotations.Operation) MyLog(com.qiwenshare.common.anno.MyLog)

Example 8 with JwtUser

use of com.qiwenshare.common.util.security.JwtUser 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 9 with JwtUser

use of com.qiwenshare.common.util.security.JwtUser in project qiwen-file by qiwenshare.

the class FiletransferController method getStorage.

@Operation(summary = "获取存储信息", description = "获取存储信息", tags = { "filetransfer" })
@RequestMapping(value = "/getstorage", method = RequestMethod.GET)
@ResponseBody
public RestResult<StorageBean> getStorage() {
    JwtUser sessionUserBean = SessionUtil.getSession();
    StorageBean storageBean = new StorageBean();
    storageBean.setUserId(sessionUserBean.getUserId());
    Long storageSize = filetransferService.selectStorageSizeByUserId(sessionUserBean.getUserId());
    StorageBean storage = new StorageBean();
    storage.setUserId(sessionUserBean.getUserId());
    storage.setStorageSize(storageSize);
    Long totalStorageSize = storageService.getTotalStorageSize(sessionUserBean.getUserId());
    storage.setTotalStorageSize(totalStorageSize);
    return RestResult.success().data(storage);
}
Also used : StorageBean(com.qiwenshare.file.domain.StorageBean) JwtUser(com.qiwenshare.common.util.security.JwtUser) Operation(io.swagger.v3.oas.annotations.Operation)

Example 10 with JwtUser

use of com.qiwenshare.common.util.security.JwtUser 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)

Aggregations

JwtUser (com.qiwenshare.common.util.security.JwtUser)30 Operation (io.swagger.v3.oas.annotations.Operation)26 MyLog (com.qiwenshare.common.anno.MyLog)16 UserFile (com.qiwenshare.file.domain.UserFile)13 RestResult (com.qiwenshare.common.result.RestResult)6 IOException (java.io.IOException)4 JSONObject (com.alibaba.fastjson.JSONObject)3 NotLoginException (com.qiwenshare.common.exception.NotLoginException)3 UploadFileVo (com.qiwenshare.file.vo.file.UploadFileVo)3 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)2 FileBean (com.qiwenshare.file.domain.FileBean)2 RecoveryFile (com.qiwenshare.file.domain.RecoveryFile)2 ShareFile (com.qiwenshare.file.domain.ShareFile)2 UserBean (com.qiwenshare.file.domain.user.UserBean)2 FileModel (com.qiwenshare.file.util.FileModel)2 FileListVo (com.qiwenshare.file.vo.file.FileListVo)2 UserLoginVo (com.qiwenshare.file.vo.user.UserLoginVo)2 LambdaUpdateWrapper (com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper)1 IPage (com.baomidou.mybatisplus.core.metadata.IPage)1 Page (com.baomidou.mybatisplus.extension.plugins.pagination.Page)1