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 035a62d..1a9609e 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 @@ -18,6 +18,7 @@ import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -27,6 +28,7 @@ import org.springframework.web.multipart.MultipartFile; import constants.Constants; import controller.BaseController; +import com.luoo.user.dto.UserInfoUpdateDto; import com.luoo.user.dto.response.UserRespDTO; import com.luoo.user.pojo.UserInfo; import com.luoo.user.service.S3Service; @@ -116,20 +118,13 @@ public class MyController extends BaseController{ } @ApiOperation(value = "2.更新个人信息", notes = "游客无法编辑个人信息") - @ApiImplicitParams({ @ApiImplicitParam(name = "nickName", value = "昵称,最多12个字符", required = false), - @ApiImplicitParam(name = "signature", value = "签名,最多50个字符", required = false), - @ApiImplicitParam(name = "birthDay", value = "生日,格式为: yyyy.MM.dd", required = false), - @ApiImplicitParam(name = "sex", value = "性别,4个值,0为男,1 为女,2为保密,不填为空", required = false) }) @PostMapping("/updateUserInfo") @GlobalInterceptor(checkAppUserLogin = true) public Result updateUserInfo(@RequestHeader(value = "token", required = false) String token, - @VerifyParam(max = 12) @RequestParam("nickName") String nickName, - @VerifyParam(max = 50) @RequestParam("signature") String signature, - @RequestParam("birthDay") String birthDay, - @RequestParam("sex") Integer sex) { - + @VerifyParam(required = true) @RequestBody UserInfoUpdateDto userInfoUpdateDto) { UserLoginDto userLoginDto = getUserLoginDto(token); UserInfo user = userInfoService.findById(userLoginDto.getUserId()); + String nickName=userInfoUpdateDto.getNickName(); if (!StringTools.isEmpty(nickName) && !nickName.equals(user.getNickName())) { long count = userInfoService.countByNickName(nickName); if (count > 0) { @@ -140,14 +135,14 @@ public class MyController extends BaseController{ if (!StringTools.isEmpty(nickName)) { user.setNickName(nickName); } - if (!StringTools.isEmpty(signature)) { - user.setSignature(signature); + if (!StringTools.isEmpty(userInfoUpdateDto.getSignature())) { + user.setSignature(userInfoUpdateDto.getSignature()); } - if (!StringTools.isEmpty(birthDay)) { - user.setBirthday(DateUtil.parse(birthDay, DateTimePatternEnum.YYYY_DOT_MM_DOT_DD.getPattern())); + if (!StringTools.isEmpty(userInfoUpdateDto.getBirthDay())) { + user.setBirthday(DateUtil.parse(userInfoUpdateDto.getBirthDay(), DateTimePatternEnum.YYYY_DOT_MM_DOT_DD.getPattern())); } - if (null!=sex) { - user.setSex(sex); + if (null!=userInfoUpdateDto.getSex()) { + user.setSex(userInfoUpdateDto.getSex()); } user.setModifyTime(new Date()); userInfoService.update(user); diff --git a/luoo_user/src/main/java/com/luoo/user/dto/UserInfoUpdateDto.java b/luoo_user/src/main/java/com/luoo/user/dto/UserInfoUpdateDto.java new file mode 100644 index 0000000..639a976 --- /dev/null +++ b/luoo_user/src/main/java/com/luoo/user/dto/UserInfoUpdateDto.java @@ -0,0 +1,19 @@ +package com.luoo.user.dto; + +import annotation.VerifyParam; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class UserInfoUpdateDto { + @VerifyParam(max = 12) + @ApiModelProperty(value = "昵称,最多12个字符", example = "雀乐-蓉江晨玥^沙顺芊润") + private String nickName; + @ApiModelProperty(value = "性别,4个值,0为男,1 为女,2为保密,不填为空", example = "0") + private Integer sex; + @ApiModelProperty(value = "签名,最多50个字符") + @VerifyParam(max = 50) + private String signature; + @ApiModelProperty(value = "生日,格式为: yyyy.MM.dd") + private String birthDay; +}