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();
}
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();
}
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);
}
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);
}
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);
}
Aggregations