From 70342071251a16e8dd50b5cc31a17f6954b173e7 Mon Sep 17 00:00:00 2001 From: Gary Date: Tue, 16 Jan 2024 23:58:46 +0800 Subject: [PATCH] 1.fix post @PathVariable issue --- .../com/luoo/user/controller/MyController.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/luoo_user/src/main/java/com/luoo/user/controller/MyController.java b/luoo_user/src/main/java/com/luoo/user/controller/MyController.java index 659b67e..d57a8cb 100644 --- a/luoo_user/src/main/java/com/luoo/user/controller/MyController.java +++ b/luoo_user/src/main/java/com/luoo/user/controller/MyController.java @@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; @@ -77,22 +78,23 @@ public class MyController { @ApiImplicitParam(name = "birthDay", value = "生日,格式为: yyyy.MM.dd", required = false), @ApiImplicitParam(name = "sex", value = "性别,4个值,0为男,1 为女,2为保密,不填为空", required = false) }) - @PostMapping("/updateUserInfo/{nickName}/{signature}/{birthDay}/{sex}") + @PostMapping("/updateUserInfo") @GlobalInterceptor(checkAppUserLogin = true) public Result updateUserInfo(@RequestHeader(value = "token", required = false) String token, - @PathVariable @VerifyParam(max = 12) String nickName, - @PathVariable @VerifyParam(max = 50) String signature, - @PathVariable String birthDay, - @PathVariable String sex) { + @VerifyParam(max = 12) @RequestParam("nickName") String nickName, + @VerifyParam(max = 50)@RequestParam("signature") String signature, + @RequestParam("birthDay") String birthDay, + @RequestParam("sex") String sex) { - if(!StringTools.isEmpty(nickName)) { + UserLoginDto userLoginDto = jwtUtil.getUserLoginDto(token); + User user = userService.findById(userLoginDto.getUserId()); + if(!StringTools.isEmpty(nickName)&&!nickName.equals(user.getNickname())) { long count = userService.countByNickName(nickName); if (count > 0) { return Result.failed(StatusCode.USER_NICK_NAME_HAS_BEEN_EXIST); } } - UserLoginDto userLoginDto = jwtUtil.getUserLoginDto(token); - User user = userService.findById(userLoginDto.getUserId()); + if(!StringTools.isEmpty(nickName)) { user.setNickname(nickName); }