Search in sources :

Example 26 with JwtUser

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();
}
Also used : 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 27 with JwtUser

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);
}
Also used : JwtUser(com.qiwenshare.common.util.security.JwtUser) FileListVo(com.qiwenshare.file.vo.file.FileListVo) Operation(io.swagger.v3.oas.annotations.Operation)

Example 28 with JwtUser

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("批量删除文件成功");
}
Also used : 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 29 with JwtUser

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();
}
Also used : JwtUser(com.qiwenshare.common.util.security.JwtUser) Operation(io.swagger.v3.oas.annotations.Operation) MyLog(com.qiwenshare.common.anno.MyLog)

Example 30 with JwtUser

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));
        }
    }
}
Also used : RestResult(com.qiwenshare.common.result.RestResult) UserLoginVo(com.qiwenshare.file.vo.user.UserLoginVo) JwtUser(com.qiwenshare.common.util.security.JwtUser) AfterReturning(org.aspectj.lang.annotation.AfterReturning)

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