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); }