Commit 66817f6b 66817f6ba9b7ba85f756f0457087fd94648a6b7a by xianghan

1.修改会员属性信息时检验手机号码

1 parent 8f0b2f33
......@@ -6,6 +6,7 @@ import com.topdraw.business.module.member.profile.domain.MemberProfileBuilder;
import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.util.Base64Util;
import com.topdraw.util.RegexUtil;
import com.topdraw.utils.RedisUtils;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.business.module.member.profile.repository.MemberProfileRepository;
......@@ -141,6 +142,13 @@ public class MemberProfileServiceImpl implements MemberProfileService {
memberProfile.setGender(_memberProfileDTO1.getGender());
}
String phone = resources.getPhone();
if (StringUtils.isNotBlank(phone) && RegexUtil.mobileRegex(phone)) {
memberProfile.setPhone(phone);
} else {
memberProfile.setPhone(_memberProfileDTO1.getPhone());
}
MemberProfile _memberProfile = this.memberProfileRepository.save(memberProfile);
MemberProfileDTO memberProfileDTO = new MemberProfileDTO();
......
package com.topdraw.util;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @author :
* @description:
* @function :
* @date :Created in 2022/8/14 0:05
* @version: :
* @modified By:
* @since : modified in 2022/8/14 0:05
*/
public class RegexUtil {
public static boolean mobileRegex(String mobile){
// String pattern = "0?(13|14|15|17|18|19)[0-9]{9}";
String pattern = "^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\\d{8}$";
Pattern r = Pattern.compile(pattern);
Matcher m = r.matcher(mobile);
return m.find();
}
public static boolean appPasswordRegex(String password) {
String pattern = "^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])[a-zA-Z0-9]{8,25}$";
Pattern r = Pattern.compile(pattern);
Matcher m = r.matcher(password);
return m.find();
}
}