代码优化
This commit is contained in:
parent
b608c35d78
commit
83e3c37707
@ -1,12 +1,7 @@
|
|||||||
package com.qiwenshare.file.api;
|
package com.qiwenshare.file.api;
|
||||||
|
|
||||||
import com.qiwenshare.common.cbb.RestResult;
|
|
||||||
import com.qiwenshare.file.domain.FileBean;
|
|
||||||
import com.qiwenshare.file.domain.StorageBean;
|
import com.qiwenshare.file.domain.StorageBean;
|
||||||
import com.qiwenshare.file.domain.UserBean;
|
import com.qiwenshare.file.dto.UploadFileDTO;
|
||||||
import com.qiwenshare.file.dto.UploadFileDto;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
@ -21,7 +16,7 @@ public interface IFiletransferService {
|
|||||||
* @param request 请求
|
* @param request 请求
|
||||||
* @param UploadFileDto 文件信息
|
* @param UploadFileDto 文件信息
|
||||||
*/
|
*/
|
||||||
void uploadFile(HttpServletRequest request, UploadFileDto UploadFileDto, Long userId);
|
void uploadFile(HttpServletRequest request, UploadFileDTO UploadFileDto, Long userId);
|
||||||
|
|
||||||
StorageBean selectStorageBean(StorageBean storageBean);
|
StorageBean selectStorageBean(StorageBean storageBean);
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ public class OpenAPIConfig {
|
|||||||
public OpenAPI qiwenFileOpenAPI() {
|
public OpenAPI qiwenFileOpenAPI() {
|
||||||
return new OpenAPI()
|
return new OpenAPI()
|
||||||
.info(new Info().title("qiwen-file API")
|
.info(new Info().title("qiwen-file API")
|
||||||
.description("desc")
|
.description("基于springboot + vue 框架开发的Web文件系统,旨在为用户提供一个简单、方便的文件存储方案,能够以完善的目录结构体系,对文件进行管理 。")
|
||||||
.version("v0.0.1")
|
.version("v0.0.1")
|
||||||
.license(new License().name("MIT").url("http://springdoc.org")))
|
.license(new License().name("MIT").url("http://springdoc.org")))
|
||||||
.externalDocs(new ExternalDocumentation()
|
.externalDocs(new ExternalDocumentation()
|
||||||
|
@ -32,7 +32,7 @@ import java.util.concurrent.Executors;
|
|||||||
|
|
||||||
import static com.qiwenshare.common.util.FileUtil.getFileExtendsByType;
|
import static com.qiwenshare.common.util.FileUtil.getFileExtendsByType;
|
||||||
|
|
||||||
@Tag(name = "文件接口", description = "进行文件的基本操作")
|
@Tag(name = "file", description = "该接口为文件接口,主要用来做一些文件的基本操作,如创建目录,删除,移动,复制等。")
|
||||||
@RestController
|
@RestController
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RequestMapping("/file")
|
@RequestMapping("/file")
|
||||||
@ -54,10 +54,10 @@ public class FileController {
|
|||||||
public static long treeid = 0;
|
public static long treeid = 0;
|
||||||
|
|
||||||
|
|
||||||
@Operation(summary = "创建文件")
|
@Operation(summary = "创建文件", description = "目录(文件夹)的创建", tags = {"file"})
|
||||||
@RequestMapping(value = "/createfile", method = RequestMethod.POST)
|
@RequestMapping(value = "/createfile", method = RequestMethod.POST)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public RestResult<String> createFile(@RequestBody CreateFileDto createFileDto, @RequestHeader("token") String token) {
|
public RestResult<String> createFile(@RequestBody CreateFileDTO createFileDto, @RequestHeader("token") String token) {
|
||||||
RestResult<String> restResult = new RestResult<>();
|
RestResult<String> restResult = new RestResult<>();
|
||||||
if (!operationCheck(token).isSuccess()){
|
if (!operationCheck(token).isSuccess()){
|
||||||
return operationCheck(token);
|
return operationCheck(token);
|
||||||
@ -86,10 +86,10 @@ public class FileController {
|
|||||||
return restResult;
|
return restResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "文件重命名")
|
@Operation(summary = "文件重命名", description = "文件重命名", tags = {"file"})
|
||||||
@RequestMapping(value = "/renamefile", method = RequestMethod.POST)
|
@RequestMapping(value = "/renamefile", method = RequestMethod.POST)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public RestResult<String> renameFile(@RequestBody RenameFileDto renameFileDto, @RequestHeader("token") String token) {
|
public RestResult<String> renameFile(@RequestBody RenameFileDTO renameFileDto, @RequestHeader("token") String token) {
|
||||||
RestResult<String> restResult = new RestResult<>();
|
RestResult<String> restResult = new RestResult<>();
|
||||||
if (!operationCheck(token).isSuccess()){
|
if (!operationCheck(token).isSuccess()){
|
||||||
return operationCheck(token);
|
return operationCheck(token);
|
||||||
@ -162,10 +162,10 @@ public class FileController {
|
|||||||
// return null;
|
// return null;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@Operation(summary = "获取文件列表")
|
@Operation(summary = "获取文件列表", description = "用来做前台列表展示", tags = {"file"})
|
||||||
@RequestMapping(value = "/getfilelist", method = RequestMethod.GET)
|
@RequestMapping(value = "/getfilelist", method = RequestMethod.GET)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public RestResult<List<Map<String, Object>>> getFileList(FileListDto fileListDto, @RequestHeader("token") String token){
|
public RestResult<List<Map<String, Object>>> getFileList(FileListDTO fileListDto, @RequestHeader("token") String token){
|
||||||
RestResult<List<Map<String, Object>>> restResult = new RestResult<>();
|
RestResult<List<Map<String, Object>>> restResult = new RestResult<>();
|
||||||
UserFile userFile = new UserFile();
|
UserFile userFile = new UserFile();
|
||||||
if(qiwenFileConfig.isShareMode()){
|
if(qiwenFileConfig.isShareMode()){
|
||||||
@ -195,7 +195,7 @@ public class FileController {
|
|||||||
return restResult;
|
return restResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "批量删除文件")
|
@Operation(summary = "批量删除文件", description = "批量删除文件", tags = {"file"})
|
||||||
@RequestMapping(value = "/batchdeletefile", method = RequestMethod.POST)
|
@RequestMapping(value = "/batchdeletefile", method = RequestMethod.POST)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public RestResult<String> deleteImageByIds(@RequestBody BatchDeleteFileDTO batchDeleteFileDto, @RequestHeader("token") String token) {
|
public RestResult<String> deleteImageByIds(@RequestBody BatchDeleteFileDTO batchDeleteFileDto, @RequestHeader("token") String token) {
|
||||||
@ -215,10 +215,10 @@ public class FileController {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "删除文件")
|
@Operation(summary = "删除文件", description = "可以删除文件或者目录", tags = {"file"})
|
||||||
@RequestMapping(value = "/deletefile", method = RequestMethod.POST)
|
@RequestMapping(value = "/deletefile", method = RequestMethod.POST)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String deleteFile(@RequestBody DeleteFileDto deleteFileDto, @RequestHeader("token") String token) {
|
public String deleteFile(@RequestBody DeleteFileDTO deleteFileDto, @RequestHeader("token") String token) {
|
||||||
RestResult<String> result = new RestResult<String>();
|
RestResult<String> result = new RestResult<String>();
|
||||||
if (!operationCheck(token).isSuccess()){
|
if (!operationCheck(token).isSuccess()){
|
||||||
return JSON.toJSONString(operationCheck(token));
|
return JSON.toJSONString(operationCheck(token));
|
||||||
@ -234,10 +234,10 @@ public class FileController {
|
|||||||
return resultJson;
|
return resultJson;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "解压文件")
|
@Operation(summary = "解压文件", description = "压缩功能为体验功能,目前持续优化中。", tags = {"file"})
|
||||||
@RequestMapping(value = "/unzipfile", method = RequestMethod.POST)
|
@RequestMapping(value = "/unzipfile", method = RequestMethod.POST)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public RestResult<String> unzipFile(@RequestBody UnzipFileDto unzipFileDto, @RequestHeader("token") String token) {
|
public RestResult<String> unzipFile(@RequestBody UnzipFileDTO unzipFileDto, @RequestHeader("token") String token) {
|
||||||
RestResult<String> result = new RestResult<String>();
|
RestResult<String> result = new RestResult<String>();
|
||||||
if (!operationCheck(token).isSuccess()){
|
if (!operationCheck(token).isSuccess()){
|
||||||
return operationCheck(token);
|
return operationCheck(token);
|
||||||
@ -321,10 +321,10 @@ public class FileController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Operation(summary = "文件移动")
|
@Operation(summary = "文件移动", description = "可以移动文件或者目录", tags = {"file"})
|
||||||
@RequestMapping(value = "/movefile", method = RequestMethod.POST)
|
@RequestMapping(value = "/movefile", method = RequestMethod.POST)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public RestResult<String> moveFile(@RequestBody MoveFileDto moveFileDto, @RequestHeader("token") String token) {
|
public RestResult<String> moveFile(@RequestBody MoveFileDTO moveFileDto, @RequestHeader("token") String token) {
|
||||||
RestResult<String> result = new RestResult<String>();
|
RestResult<String> result = new RestResult<String>();
|
||||||
if (!operationCheck(token).isSuccess()){
|
if (!operationCheck(token).isSuccess()){
|
||||||
return operationCheck(token);
|
return operationCheck(token);
|
||||||
@ -339,10 +339,10 @@ public class FileController {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "批量移动文件")
|
@Operation(summary = "批量移动文件", description = "可以同时选择移动多个文件或者目录", tags = {"file"})
|
||||||
@RequestMapping(value = "/batchmovefile", method = RequestMethod.POST)
|
@RequestMapping(value = "/batchmovefile", method = RequestMethod.POST)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public RestResult<String> batchMoveFile(@RequestBody BatchMoveFileDto batchMoveFileDto, @RequestHeader("token") String token) {
|
public RestResult<String> batchMoveFile(@RequestBody BatchMoveFileDTO batchMoveFileDto, @RequestHeader("token") String token) {
|
||||||
|
|
||||||
RestResult<String> result = new RestResult<String>();
|
RestResult<String> result = new RestResult<String>();
|
||||||
if (!operationCheck(token).isSuccess()) {
|
if (!operationCheck(token).isSuccess()) {
|
||||||
@ -382,7 +382,7 @@ public class FileController {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "通过文件类型选择文件")
|
@Operation(summary = "通过文件类型选择文件", description = "该接口可以实现文件格式分类查看", tags = {"file"})
|
||||||
@RequestMapping(value = "/selectfilebyfiletype", method = RequestMethod.GET)
|
@RequestMapping(value = "/selectfilebyfiletype", method = RequestMethod.GET)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public RestResult<List<Map<String, Object>>> selectFileByFileType(int fileType, @RequestHeader("token") String token) {
|
public RestResult<List<Map<String, Object>>> selectFileByFileType(int fileType, @RequestHeader("token") String token) {
|
||||||
@ -409,7 +409,7 @@ public class FileController {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "获取文件树")
|
@Operation(summary = "获取文件树", description = "文件移动的时候需要用到该接口,用来展示目录树,展示机制为饱汉模式", tags = {"file"})
|
||||||
@RequestMapping(value = "/getfiletree", method = RequestMethod.GET)
|
@RequestMapping(value = "/getfiletree", method = RequestMethod.GET)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public RestResult<TreeNode> getFileTree(@RequestHeader("token") String token){
|
public RestResult<TreeNode> getFileTree(@RequestHeader("token") String token){
|
||||||
|
@ -1,14 +1,7 @@
|
|||||||
package com.qiwenshare.file.controller;
|
package com.qiwenshare.file.controller;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.aliyun.oss.OSS;
|
|
||||||
import com.aliyun.oss.model.OSSObject;
|
|
||||||
import com.qiwenshare.common.cbb.DateUtil;
|
import com.qiwenshare.common.cbb.DateUtil;
|
||||||
import com.qiwenshare.common.operation.FileOperation;
|
|
||||||
import com.qiwenshare.common.oss.AliyunOSSDownload;
|
|
||||||
import com.qiwenshare.common.util.FileUtil;
|
import com.qiwenshare.common.util.FileUtil;
|
||||||
import com.qiwenshare.common.util.PathUtil;
|
|
||||||
import com.qiwenshare.common.cbb.RestResult;
|
import com.qiwenshare.common.cbb.RestResult;
|
||||||
import com.qiwenshare.file.api.IFileService;
|
import com.qiwenshare.file.api.IFileService;
|
||||||
import com.qiwenshare.file.api.IFiletransferService;
|
import com.qiwenshare.file.api.IFiletransferService;
|
||||||
@ -19,7 +12,7 @@ import com.qiwenshare.file.domain.FileBean;
|
|||||||
import com.qiwenshare.file.domain.StorageBean;
|
import com.qiwenshare.file.domain.StorageBean;
|
||||||
import com.qiwenshare.file.domain.UserBean;
|
import com.qiwenshare.file.domain.UserBean;
|
||||||
import com.qiwenshare.file.domain.UserFile;
|
import com.qiwenshare.file.domain.UserFile;
|
||||||
import com.qiwenshare.file.dto.UploadFileDto;
|
import com.qiwenshare.file.dto.UploadFileDTO;
|
||||||
import com.qiwenshare.file.vo.file.UploadFileVo;
|
import com.qiwenshare.file.vo.file.UploadFileVo;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
@ -28,13 +21,11 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.io.*;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Tag(name = "文件传输", description = "进行文件的上传和下载")
|
@Tag(name = "filetransfer", description = "该接口为文件传输接口,主要用来做文件的上传和下载")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/filetransfer")
|
@RequestMapping("/filetransfer")
|
||||||
public class FiletransferController {
|
public class FiletransferController {
|
||||||
@ -54,10 +45,10 @@ public class FiletransferController {
|
|||||||
@Resource
|
@Resource
|
||||||
IUserFileService userFileService;
|
IUserFileService userFileService;
|
||||||
|
|
||||||
@Operation(summary = "极速上传")
|
@Operation(summary = "极速上传", description = "校验文件MD5判断文件是否存在,如果存在直接上传成功并返回skipUpload=true,如果不存在返回skipUpload=false需要再次调用该接口的POST方法", tags = {"filetransfer"})
|
||||||
@RequestMapping(value = "/uploadfile", method = RequestMethod.GET)
|
@RequestMapping(value = "/uploadfile", method = RequestMethod.GET)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public RestResult<UploadFileVo> uploadFileSpeed(HttpServletRequest request, UploadFileDto uploadFileDto, @RequestHeader("token") String token) {
|
public RestResult<UploadFileVo> uploadFileSpeed(HttpServletRequest request, UploadFileDTO uploadFileDto, @RequestHeader("token") String token) {
|
||||||
RestResult<UploadFileVo> restResult = new RestResult<UploadFileVo>();
|
RestResult<UploadFileVo> restResult = new RestResult<UploadFileVo>();
|
||||||
UserBean sessionUserBean = userService.getUserBeanByToken(token);
|
UserBean sessionUserBean = userService.getUserBeanByToken(token);
|
||||||
if (sessionUserBean == null){
|
if (sessionUserBean == null){
|
||||||
@ -110,10 +101,10 @@ public class FiletransferController {
|
|||||||
* @param request
|
* @param request
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Operation(summary = "上传文件")
|
@Operation(summary = "上传文件", description = "真正的上次文件接口", tags = {"filetransfer"})
|
||||||
@RequestMapping(value = "/uploadfile", method = RequestMethod.POST)
|
@RequestMapping(value = "/uploadfile", method = RequestMethod.POST)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public RestResult<UploadFileVo> uploadFile(HttpServletRequest request, UploadFileDto uploadFileDto, @RequestHeader("token") String token) {
|
public RestResult<UploadFileVo> uploadFile(HttpServletRequest request, UploadFileDTO uploadFileDto, @RequestHeader("token") String token) {
|
||||||
RestResult<UploadFileVo> restResult = new RestResult<>();
|
RestResult<UploadFileVo> restResult = new RestResult<>();
|
||||||
UserBean sessionUserBean = userService.getUserBeanByToken(token);
|
UserBean sessionUserBean = userService.getUserBeanByToken(token);
|
||||||
if (sessionUserBean == null){
|
if (sessionUserBean == null){
|
||||||
@ -135,7 +126,7 @@ public class FiletransferController {
|
|||||||
return restResult;
|
return restResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "获取存储信息")
|
@Operation(summary = "获取存储信息", description = "获取存储信息", tags = {"filetransfer"})
|
||||||
@RequestMapping(value = "/getstorage", method = RequestMethod.GET)
|
@RequestMapping(value = "/getstorage", method = RequestMethod.GET)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public RestResult<StorageBean> getStorage(@RequestHeader("token") String token) {
|
public RestResult<StorageBean> getStorage(@RequestHeader("token") String token) {
|
||||||
|
@ -8,6 +8,7 @@ import com.qiwenshare.common.util.JjwtUtil;
|
|||||||
import com.qiwenshare.file.api.IUserService;
|
import com.qiwenshare.file.api.IUserService;
|
||||||
import com.qiwenshare.file.config.QiwenFileConfig;
|
import com.qiwenshare.file.config.QiwenFileConfig;
|
||||||
import com.qiwenshare.file.domain.UserBean;
|
import com.qiwenshare.file.domain.UserBean;
|
||||||
|
import com.qiwenshare.file.dto.RegisterDTO;
|
||||||
import com.qiwenshare.file.vo.user.UserLoginVo;
|
import com.qiwenshare.file.vo.user.UserLoginVo;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
@ -28,7 +29,7 @@ import java.util.Map;
|
|||||||
*
|
*
|
||||||
* @author ma116
|
* @author ma116
|
||||||
*/
|
*/
|
||||||
@Tag(name = "user", description = "进行用户的基本操作")
|
@Tag(name = "user", description = "该接口为用户接口,主要做用户登录,注册和校验token")
|
||||||
@RestController
|
@RestController
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RequestMapping("/user")
|
@RequestMapping("/user")
|
||||||
@ -50,12 +51,13 @@ public class UserController {
|
|||||||
*/
|
*/
|
||||||
public static final String CURRENT_MODULE = "用户管理";
|
public static final String CURRENT_MODULE = "用户管理";
|
||||||
|
|
||||||
@Operation(summary = "用户注册")
|
@Operation(summary = "用户注册", description = "注册账号", tags = {"user"})
|
||||||
@PostMapping(value = "/adduser")
|
@PostMapping(value = "/adduser")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public RestResult<String> addUser(@RequestBody UserBean userBean) {
|
public RestResult<String> addUser(@RequestBody RegisterDTO registerDTO) {
|
||||||
RestResult<String> restResult = null;
|
RestResult<String> restResult = null;
|
||||||
|
UserBean userBean = new UserBean();
|
||||||
|
BeanUtil.copyProperties(registerDTO, userBean);
|
||||||
restResult = userService.registerUser(userBean);
|
restResult = userService.registerUser(userBean);
|
||||||
|
|
||||||
return restResult;
|
return restResult;
|
||||||
@ -96,7 +98,7 @@ public class UserController {
|
|||||||
return restResult;
|
return restResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "检查用户登录信息", description = "", tags = {"user"})
|
@Operation(summary = "检查用户登录信息", description = "验证token的有效性", tags = {"user"})
|
||||||
@GetMapping("/checkuserlogininfo")
|
@GetMapping("/checkuserlogininfo")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public RestResult<UserBean> checkUserLoginInfo(@RequestHeader("token") String token) {
|
public RestResult<UserBean> checkUserLoginInfo(@RequestHeader("token") String token) {
|
||||||
@ -121,23 +123,23 @@ public class UserController {
|
|||||||
return restResult;
|
return restResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "得到用户信息通过id", description = "", tags = {"user"})
|
// @Operation(summary = "得到用户信息通过id", description = "", tags = {"user"})
|
||||||
@GetMapping("/getuserinfobyid")
|
// @GetMapping("/getuserinfobyid")
|
||||||
@ResponseBody
|
// @ResponseBody
|
||||||
public String getUserInfoById(int userId) {
|
// public String getUserInfoById(int userId) {
|
||||||
RestResult<UserBean> restResult = new RestResult<UserBean>();
|
// RestResult<UserBean> restResult = new RestResult<UserBean>();
|
||||||
|
//
|
||||||
UserBean userBean = userService.getById(userId);
|
// UserBean userBean = userService.getById(userId);
|
||||||
if (userBean == null) {
|
// if (userBean == null) {
|
||||||
restResult.setSuccess(false);
|
// restResult.setSuccess(false);
|
||||||
restResult.setErrorCode("100001");
|
// restResult.setErrorCode("100001");
|
||||||
restResult.setErrorMessage("用户不存在!");
|
// restResult.setErrorMessage("用户不存在!");
|
||||||
} else {
|
// } else {
|
||||||
restResult.setSuccess(true);
|
// restResult.setSuccess(true);
|
||||||
restResult.setData(userBean);
|
// restResult.setData(userBean);
|
||||||
}
|
// }
|
||||||
String resultJson = JSON.toJSONString(restResult);
|
// String resultJson = JSON.toJSONString(restResult);
|
||||||
return resultJson;
|
// return resultJson;
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package com.qiwenshare.file.dto;
|
package com.qiwenshare.file.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
@Schema(name = "批量删除文件DTO",required = true)
|
||||||
public class BatchDeleteFileDTO {
|
public class BatchDeleteFileDTO {
|
||||||
|
@Schema(description="文件集合")
|
||||||
private String files;
|
private String files;
|
||||||
|
|
||||||
|
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.qiwenshare.file.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Schema(name = "批量移动文件DTO",required = true)
|
||||||
|
public class BatchMoveFileDTO {
|
||||||
|
@Schema(description="文件集合")
|
||||||
|
private String files;
|
||||||
|
@Schema(description="文件路径")
|
||||||
|
private String filePath;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,12 +0,0 @@
|
|||||||
package com.qiwenshare.file.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class BatchMoveFileDto {
|
|
||||||
|
|
||||||
private String files;
|
|
||||||
private String filePath;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.qiwenshare.file.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Schema(name = "创建文件DTO",required = true)
|
||||||
|
public class CreateFileDTO {
|
||||||
|
@Schema(description="文件名")
|
||||||
|
private String fileName;
|
||||||
|
@Schema(description="文件路径")
|
||||||
|
private String filePath;
|
||||||
|
}
|
@ -1,9 +0,0 @@
|
|||||||
package com.qiwenshare.file.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class CreateFileDto {
|
|
||||||
private String fileName;
|
|
||||||
private String filePath;
|
|
||||||
}
|
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.qiwenshare.file.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Schema(name = "删除文件DTO",required = true)
|
||||||
|
public class DeleteFileDTO {
|
||||||
|
@Schema(description = "用户文件id")
|
||||||
|
private Long userFileId;
|
||||||
|
@Schema(description = "文件路径")
|
||||||
|
private String filePath;
|
||||||
|
@Schema(description = "文件名")
|
||||||
|
private String fileName;
|
||||||
|
@Schema(description = "是否是目录")
|
||||||
|
private Integer isDir;
|
||||||
|
}
|
@ -1,11 +0,0 @@
|
|||||||
package com.qiwenshare.file.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class DeleteFileDto {
|
|
||||||
private Long userFileId;
|
|
||||||
private String filePath;
|
|
||||||
private String fileName;
|
|
||||||
private Integer isDir;
|
|
||||||
}
|
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.qiwenshare.file.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Schema(name = "文件列表DTO",required = true)
|
||||||
|
public class FileListDTO {
|
||||||
|
@Schema(description = "文件路径")
|
||||||
|
private String filePath;
|
||||||
|
@Schema(description = "当前页码")
|
||||||
|
private Long currentPage;
|
||||||
|
@Schema(description = "一页显示数量")
|
||||||
|
private Long pageCount;
|
||||||
|
}
|
@ -1,11 +0,0 @@
|
|||||||
package com.qiwenshare.file.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class FileListDto {
|
|
||||||
private String filePath;
|
|
||||||
|
|
||||||
private Long currentPage;
|
|
||||||
private Long pageCount;
|
|
||||||
}
|
|
@ -0,0 +1,27 @@
|
|||||||
|
package com.qiwenshare.file.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Schema(name = "移动文件DTO",required = true)
|
||||||
|
public class MoveFileDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件路径
|
||||||
|
*/
|
||||||
|
@Schema(description = "文件路径")
|
||||||
|
private String filePath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件名
|
||||||
|
*/
|
||||||
|
@Schema(description = "文件名")
|
||||||
|
private String fileName;
|
||||||
|
|
||||||
|
@Schema(description = "旧文件名")
|
||||||
|
private String oldFilePath;
|
||||||
|
@Schema(description = "扩展名")
|
||||||
|
private String extendName;
|
||||||
|
|
||||||
|
}
|
@ -1,20 +0,0 @@
|
|||||||
package com.qiwenshare.file.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class MoveFileDto {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件路径
|
|
||||||
*/
|
|
||||||
private String filePath;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件名
|
|
||||||
*/
|
|
||||||
private String fileName;
|
|
||||||
private String oldFilePath;
|
|
||||||
private String extendName;
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.qiwenshare.file.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Schema(name = "用户注册DTO",required = true)
|
||||||
|
public class RegisterDTO {
|
||||||
|
@Schema(description = "用户名")
|
||||||
|
private String username;
|
||||||
|
@Schema(description = "手机号")
|
||||||
|
private String telephone;
|
||||||
|
@Schema(description = "密码")
|
||||||
|
private String password;
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package com.qiwenshare.file.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Schema(name = "重命名文件DTO",required = true)
|
||||||
|
public class RenameFileDTO {
|
||||||
|
private Long userFileId;
|
||||||
|
/**
|
||||||
|
* 文件路径
|
||||||
|
*/
|
||||||
|
@Schema(description = "文件路径")
|
||||||
|
private String filePath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件名
|
||||||
|
*/
|
||||||
|
@Schema(description = "文件名")
|
||||||
|
private String fileName;
|
||||||
|
@Schema(description = "是否是目录")
|
||||||
|
private Integer isDir;
|
||||||
|
@Schema(description = "旧文件名")
|
||||||
|
private String oldFileName;
|
||||||
|
@Schema(description = "是否是OSS")
|
||||||
|
private Integer isOSS;
|
||||||
|
}
|
@ -1,22 +0,0 @@
|
|||||||
package com.qiwenshare.file.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class RenameFileDto {
|
|
||||||
private Long userFileId;
|
|
||||||
/**
|
|
||||||
* 文件路径
|
|
||||||
*/
|
|
||||||
private String filePath;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件名
|
|
||||||
*/
|
|
||||||
private String fileName;
|
|
||||||
|
|
||||||
private Integer isDir;
|
|
||||||
|
|
||||||
private String oldFileName;
|
|
||||||
private Integer isOSS;
|
|
||||||
}
|
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.qiwenshare.file.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Schema(name = "解压缩文件DTO",required = true)
|
||||||
|
public class UnzipFileDTO {
|
||||||
|
@Schema(description = "文件url")
|
||||||
|
private String fileUrl;
|
||||||
|
@Schema(description = "文件路径")
|
||||||
|
private String filePath;
|
||||||
|
}
|
@ -1,9 +0,0 @@
|
|||||||
package com.qiwenshare.file.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class UnzipFileDto {
|
|
||||||
private String fileUrl;
|
|
||||||
private String filePath;
|
|
||||||
}
|
|
@ -11,43 +11,46 @@ import javax.persistence.*;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Schema(name = "上传文件DTO",required = true)
|
@Schema(name = "上传文件DTO",required = true)
|
||||||
public class UploadFileDto {
|
public class UploadFileDTO {
|
||||||
|
|
||||||
/**
|
@Schema(description = "文件路径")
|
||||||
* 文件路径
|
|
||||||
*/
|
|
||||||
private String filePath;
|
private String filePath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传时间
|
* 上传时间
|
||||||
*/
|
*/
|
||||||
|
@Schema(description = "上传时间")
|
||||||
private String uploadTime;
|
private String uploadTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 扩展名
|
* 扩展名
|
||||||
*/
|
*/
|
||||||
|
@Schema(description = "扩展名")
|
||||||
private String extendName;
|
private String extendName;
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件名
|
@Schema(description = "文件名")
|
||||||
*/
|
|
||||||
private String filename;
|
private String filename;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件大小
|
* 文件大小
|
||||||
*/
|
*/
|
||||||
|
@Schema(description = "文件大小")
|
||||||
private Long fileSize;
|
private Long fileSize;
|
||||||
|
|
||||||
|
@Schema(description = "切片数量")
|
||||||
private int chunkNumber;
|
private int chunkNumber;
|
||||||
|
|
||||||
|
@Schema(description = "切片大小")
|
||||||
private long chunkSize;
|
private long chunkSize;
|
||||||
|
|
||||||
|
@Schema(description = "所有切片")
|
||||||
private int totalChunks;
|
private int totalChunks;
|
||||||
|
@Schema(description = "总大小")
|
||||||
private long totalSize;
|
private long totalSize;
|
||||||
|
@Schema(description = "当前切片大小")
|
||||||
private long currentChunkSize;
|
private long currentChunkSize;
|
||||||
|
@Schema(description = "md5码")
|
||||||
private String identifier;
|
private String identifier;
|
||||||
|
|
||||||
}
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
//package com.qiwenshare.file.interceptor;
|
||||||
|
//
|
||||||
|
//import com.qiwenshare.file.api.IUserService;
|
||||||
|
//import com.qiwenshare.file.domain.UserBean;
|
||||||
|
//import lombok.extern.slf4j.Slf4j;
|
||||||
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
//import org.springframework.http.HttpHeaders;
|
||||||
|
//import org.springframework.web.servlet.HandlerInterceptor;
|
||||||
|
//import org.springframework.web.servlet.ModelAndView;
|
||||||
|
//
|
||||||
|
//import javax.servlet.http.HttpServletRequest;
|
||||||
|
//import javax.servlet.http.HttpServletResponse;
|
||||||
|
//
|
||||||
|
///**
|
||||||
|
// * token验证拦截
|
||||||
|
// */
|
||||||
|
//@Slf4j
|
||||||
|
//public class AuthenticationInterceptor implements HandlerInterceptor {
|
||||||
|
// @Autowired
|
||||||
|
// private IUserService userService;
|
||||||
|
// @Override
|
||||||
|
// public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
|
||||||
|
// throws Exception {
|
||||||
|
// log.info("---------------------------------------------------------");
|
||||||
|
// // 取得token
|
||||||
|
// String tokenHeader = request.getHeader(HttpHeaders.AUTHORIZATION);
|
||||||
|
// if (tokenHeader == null || "".equals(tokenHeader)) {
|
||||||
|
// throw new Exception("token不存在");
|
||||||
|
// }
|
||||||
|
// if (!tokenHeader.startsWith("Bearer")) {
|
||||||
|
// throw new Exception("token格式错误");
|
||||||
|
// }
|
||||||
|
// String token = tokenHeader.replace("Bearer", "");
|
||||||
|
// UserBean userBean = userService.getUserBeanByToken(token);
|
||||||
|
// if (userBean == null) {
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
|
||||||
|
// ModelAndView modelAndView) throws Exception {
|
||||||
|
// // TODO Auto-generated method stub
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
|
||||||
|
// throws Exception {
|
||||||
|
// // TODO Auto-generated method stub
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
//
|
@ -18,11 +18,10 @@ import com.qiwenshare.file.api.IFiletransferService;
|
|||||||
import com.qiwenshare.common.domain.AliyunOSS;
|
import com.qiwenshare.common.domain.AliyunOSS;
|
||||||
import com.qiwenshare.file.config.QiwenFileConfig;
|
import com.qiwenshare.file.config.QiwenFileConfig;
|
||||||
import com.qiwenshare.file.domain.UserFile;
|
import com.qiwenshare.file.domain.UserFile;
|
||||||
import com.qiwenshare.file.dto.UploadFileDto;
|
import com.qiwenshare.file.dto.UploadFileDTO;
|
||||||
import com.qiwenshare.file.mapper.FileMapper;
|
import com.qiwenshare.file.mapper.FileMapper;
|
||||||
import com.qiwenshare.file.domain.FileBean;
|
import com.qiwenshare.file.domain.FileBean;
|
||||||
import com.qiwenshare.file.domain.StorageBean;
|
import com.qiwenshare.file.domain.StorageBean;
|
||||||
import com.qiwenshare.file.domain.UserBean;
|
|
||||||
import com.qiwenshare.file.mapper.StorageMapper;
|
import com.qiwenshare.file.mapper.StorageMapper;
|
||||||
import com.qiwenshare.file.mapper.UserFileMapper;
|
import com.qiwenshare.file.mapper.UserFileMapper;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -44,7 +43,7 @@ public class FiletransferService implements IFiletransferService {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void uploadFile(HttpServletRequest request, UploadFileDto UploadFileDto, Long userId) {
|
public void uploadFile(HttpServletRequest request, UploadFileDTO UploadFileDto, Long userId) {
|
||||||
AliyunOSS oss = qiwenFileConfig.getAliyun().getOss();
|
AliyunOSS oss = qiwenFileConfig.getAliyun().getOss();
|
||||||
request.setAttribute("oss", oss);
|
request.setAttribute("oss", oss);
|
||||||
Uploader uploader;
|
Uploader uploader;
|
||||||
|
4
pom.xml
4
pom.xml
@ -27,12 +27,12 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springdoc</groupId>
|
<groupId>org.springdoc</groupId>
|
||||||
<artifactId>springdoc-openapi-ui</artifactId>
|
<artifactId>springdoc-openapi-ui</artifactId>
|
||||||
<version>1.3.9</version>
|
<version>1.5.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.xiaoymin</groupId>
|
<groupId>com.github.xiaoymin</groupId>
|
||||||
<artifactId>knife4j-springdoc-ui</artifactId>
|
<artifactId>knife4j-springdoc-ui</artifactId>
|
||||||
<version>2.0.3</version>
|
<version>3.0.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--Swagger End-->
|
<!--Swagger End-->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
Loading…
Reference in New Issue
Block a user