|
|
|
@ -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<Void> 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);
|
|
|
|
|