diff --git a/src/main/java/com/cultural/heritage/controller/file/FileController.java b/src/main/java/com/cultural/heritage/controller/file/FileController.java index 9eaa264..ab3204b 100644 --- a/src/main/java/com/cultural/heritage/controller/file/FileController.java +++ b/src/main/java/com/cultural/heritage/controller/file/FileController.java @@ -141,6 +141,34 @@ public class FileController { } + @PostMapping("/upload/only") + @Operation(summary = "单独文件上传(只返回url)", description = "参数:file,文件对象(multipartFile),权限:所有人,方法名:uploadServerFile") + public String uploadOnlyServerFile(@RequestPart("file")MultipartFile multipartFile, HttpServletRequest request) { +// + // 校验文件 + validFile(multipartFile, null); + // 文件目录:根据业务、用户来划分 + String uuid = RandomStringUtils.randomAlphabetic(8); + String filename = uuid + "-" + multipartFile.getOriginalFilename(); + String filepath = String.format("/%s/%s/%s", "single", "yt", filename); + + // 判断目录是否存在 + File file = new File(FileConstant.SERVER_UPLOAD_DIR, filepath); + if (!file.exists()) { + // 创建目录 + boolean mkdirs = file.mkdirs(); + if (!mkdirs) { + throw new BusinessException(ErrorCode.SYSTEM_ERROR, "创建目录失败"); + } + } + //返回可访问地址 + return iHweiYunOBSService.fileUpload(multipartFile, "feiyi" + filepath); + } + + + + + /** diff --git a/src/main/java/com/cultural/heritage/controller/user/UserController.java b/src/main/java/com/cultural/heritage/controller/user/UserController.java index e5aefe8..7248c36 100644 --- a/src/main/java/com/cultural/heritage/controller/user/UserController.java +++ b/src/main/java/com/cultural/heritage/controller/user/UserController.java @@ -105,18 +105,34 @@ public class UserController { /** - * 退出登录 + * Web端管理员退出登录 * @param request http * @return 是否退出登录成功 */ @PostMapping("/logout") @Operation(summary = "Web端管理员退出登录", description = "参数:无,权限:所有人,方法名:userLogout") + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) public BaseResponse userLogout(HttpServletRequest request) { boolean result = userService.userLogout(request); return ResultUtils.success(result); } + /** + * 小程序用户退出登录 + * @param request http + * @return 是否退出登录成功 + */ + @PostMapping("/mini/logout") + @Operation(summary = "小程序用户退出登录", description = "参数:无,权限:所有人,方法名:userLogout") + public BaseResponse miniUserLogout(HttpServletRequest request) { + boolean result = userService.userLogout(request); + return ResultUtils.success(result); + } + + + + /** * 小程序端(Web端)用户获取登录信息 * @param request http @@ -148,7 +164,7 @@ public class UserController { BeanUtils.copyProperties(userUpdateMyRequest, user); user.setId(loginUser.getId()); boolean result = userService.updateById(user); - ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR); + ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "用户信息更新失败"); return ResultUtils.success(true); } diff --git a/src/main/java/com/cultural/heritage/model/dto/user/UserUpdateMyRequest.java b/src/main/java/com/cultural/heritage/model/dto/user/UserUpdateMyRequest.java index 3484b2c..2649152 100644 --- a/src/main/java/com/cultural/heritage/model/dto/user/UserUpdateMyRequest.java +++ b/src/main/java/com/cultural/heritage/model/dto/user/UserUpdateMyRequest.java @@ -25,12 +25,6 @@ public class UserUpdateMyRequest implements Serializable { @Schema(description = "用户头像", example = "https://xxx/xxx.jpg") private String userAvatar; - /** - * 手机号 - */ - @Schema(description = "手机号", example = "18845892473") - private String phone; - @Serial private static final long serialVersionUID = 1L; diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 16654ef..9884d83 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -19,7 +19,7 @@ spring: # max-lifetime: 120000 - +# 生产环境 rabbitmq: host: 123.249.108.160 port: 5672 @@ -31,6 +31,18 @@ spring: prefetch: 1 +# 测试环境 +# rabbitmq: +# host: 154.8.193.216 +# port: 5672 +# username: admin +# password: cksys6509 +# virtual-host: vhost +# listener: +# simple: +# prefetch: 1 + + data: