use of com.qiwenshare.common.util.security.JwtUser in project qiwen-file by qiwenshare.
the class FileController method copyFile.
@Operation(summary = "文件复制", description = "可以复制文件或者目录", tags = { "file" })
@RequestMapping(value = "/copyfile", method = RequestMethod.POST)
@MyLog(operation = "文件复制", module = CURRENT_MODULE)
@ResponseBody
public RestResult<String> copyFile(@RequestBody CopyFileDTO copyFileDTO) {
JwtUser sessionUserBean = SessionUtil.getSession();
long userFileId = copyFileDTO.getUserFileId();
UserFile userFile = userFileService.getById(userFileId);
String oldfilePath = userFile.getFilePath();
String newfilePath = copyFileDTO.getFilePath();
String fileName = userFile.getFileName();
String extendName = userFile.getExtendName();
if (userFile.getIsDir() == 1) {
String testFilePath = oldfilePath + fileName + "/";
if (newfilePath.startsWith(testFilePath)) {
return RestResult.fail().message("原路径与目标路径冲突,不能复制");
}
}
userFileService.userFileCopy(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 selectFileByFileType.
@Operation(summary = "通过文件类型选择文件", description = "该接口可以实现文件格式分类查看", tags = { "file" })
@RequestMapping(value = "/selectfilebyfiletype", method = RequestMethod.GET)
@ResponseBody
public RestResult<List<Map<String, Object>>> selectFileByFileType(@Parameter(description = "文件类型", required = true) int fileType, @Parameter(description = "当前页", required = true) @RequestParam(defaultValue = "1") long currentPage, @Parameter(description = "页面数量", required = true) @RequestParam(defaultValue = "10") long pageCount) {
JwtUser sessionUserBean = SessionUtil.getSession();
long userId = sessionUserBean.getUserId();
IPage<FileListVo> result = userFileService.getFileByFileType(fileType, currentPage, pageCount, userId);
Map<String, Object> map = new HashMap<>();
map.put("list", result.getRecords());
map.put("total", result.getTotal());
return RestResult.success().data(map);
}
use of com.qiwenshare.common.util.security.JwtUser in project qiwen-file by qiwenshare.
the class FileController method deleteImageByIds.
@Operation(summary = "批量删除文件", description = "批量删除文件", tags = { "file" })
@RequestMapping(value = "/batchdeletefile", method = RequestMethod.POST)
@MyLog(operation = "批量删除文件", module = CURRENT_MODULE)
@ResponseBody
public RestResult<String> deleteImageByIds(@RequestBody BatchDeleteFileDTO batchDeleteFileDto) {
JwtUser sessionUserBean = SessionUtil.getSession();
List<UserFile> userFiles = JSON.parseArray(batchDeleteFileDto.getFiles(), UserFile.class);
DigestUtils.md5Hex("data");
for (UserFile userFile : userFiles) {
userFileService.deleteUserFile(userFile.getUserFileId(), sessionUserBean.getUserId());
fileDealComp.deleteESByUserFileId(userFile.getUserFileId());
}
return RestResult.success().message("批量删除文件成功");
}
use of com.qiwenshare.common.util.security.JwtUser in project qiwen-file by qiwenshare.
the class FileController method deleteFile.
@Operation(summary = "删除文件", description = "可以删除文件或者目录", tags = { "file" })
@RequestMapping(value = "/deletefile", method = RequestMethod.POST)
@MyLog(operation = "删除文件", module = CURRENT_MODULE)
@ResponseBody
public RestResult deleteFile(@RequestBody DeleteFileDTO deleteFileDto) {
JwtUser sessionUserBean = SessionUtil.getSession();
userFileService.deleteUserFile(deleteFileDto.getUserFileId(), sessionUserBean.getUserId());
fileDealComp.deleteESByUserFileId(deleteFileDto.getUserFileId());
return RestResult.success();
}
use of com.qiwenshare.common.util.security.JwtUser in project qiwen-file by qiwenshare.
the class WebLogAcpect method doAfterReturning.
@AfterReturning(returning = "ret", pointcut = "webLog()")
public void doAfterReturning(Object ret) throws Throwable {
if (ret instanceof RestResult) {
boolean isSuccess = ((RestResult) ret).getSuccess();
String errorMessage = ((RestResult) ret).getMessage();
JwtUser sessionUser = SessionUtil.getSession();
Long userId = 0L;
if (sessionUser != null) {
userId = sessionUser.getUserId();
}
Integer code = ((RestResult) ret).getCode();
if (code != null && code == 200001) {
UserLoginVo data = (UserLoginVo) ((RestResult) ret).getData();
userId = data.getUserId();
}
if (isSuccess) {
operationLogService.insertOperationLog(OperationLogUtil.getOperationLogObj(request, userId, "成功", module, operation, "操作成功"));
} else {
operationLogService.insertOperationLog(OperationLogUtil.getOperationLogObj(request, userId, "失败", module, operation, errorMessage));
}
}
}
Aggregations