|
|
@@ -3,6 +3,8 @@ package com.goafanti.user.controller;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.Base64;
|
|
|
import java.util.UUID;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
@@ -701,9 +703,27 @@ public class UserApiController extends BaseApiController {
|
|
|
User user = new User();
|
|
|
user.setId(TokenManager.getUserId());
|
|
|
user.setIdentifyName(identifyName);
|
|
|
- //user.setMobile(mobile);不修改电话号码
|
|
|
+ if(StringUtils.isNotEmpty(mobile)){
|
|
|
+ //验证手机号码格式是否正确
|
|
|
+ Pattern p = Pattern.compile("^[1][3,4,5,7,8][0-9]{9}$"); // 验证手机号
|
|
|
+ Matcher m = p.matcher(mobile);
|
|
|
+ if(!m.matches()){
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"电话号码格式不对"));
|
|
|
+ }else{
|
|
|
+ //验证手机是否存在
|
|
|
+ int i = userService.getCountByMobile(user);
|
|
|
+ if(i>0){
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"电话号码重复"));
|
|
|
+ }else{
|
|
|
+ user.setMobile(mobile);//修改电话号码
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
if(StringUtils.isNotBlank(email))user.setEmail(email);
|
|
|
user.setNickname(nickname);
|
|
|
+ if(res.getError().size()>0){
|
|
|
+ return res;
|
|
|
+ }
|
|
|
userService.updateByPrimaryKeySelective(user);
|
|
|
return res;
|
|
|
}
|