|
@@ -1,7 +1,5 @@
|
|
|
package com.caimei365.user.utils;
|
|
|
|
|
|
-import com.caimei365.user.model.ResponseJson;
|
|
|
-import com.caimei365.user.model.vo.UserLoginVo;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
|
import java.util.regex.Matcher;
|
|
@@ -22,9 +20,6 @@ public class ValidateUtil {
|
|
|
private static final String PASSWORD_PATTERN = "^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,16}$";
|
|
|
/** 机构名称验证格式 */
|
|
|
private static final String CLUB_NAME_PATTERN = "^[a-zA-Z0-9\u4e00-\u9fa5]{1,200}$";
|
|
|
- /** 用户名称验证格式 */
|
|
|
- private static final String USER_CN_NAME_PATTERN = "^[\u4e00-\u9fa5]{2,8}$";
|
|
|
- private static final String USER_EN_NAME_PATTERN = "^[a-zA-Z]{2,16}";
|
|
|
/** 统一社会信用代码验证格式 */
|
|
|
private static final String SOCIAL_CREDIT_CODE_PATTERN = "^[0-9A-HJ-NPQRTUWXY]{2}\\d{6}[0-9A-HJ-NPQRTUWXY]{10}$";
|
|
|
|
|
@@ -33,16 +28,16 @@ public class ValidateUtil {
|
|
|
*
|
|
|
* @param mobile 手机号
|
|
|
*/
|
|
|
- public static ResponseJson validateMobile(String mobile) {
|
|
|
+ public static String validateMobile(String mobile) {
|
|
|
if (StringUtils.isEmpty(mobile) || StringUtils.isBlank(mobile)) {
|
|
|
- return ResponseJson.error("手机号不可为空");
|
|
|
+ return "手机号不可为空";
|
|
|
} else {
|
|
|
Pattern pattern = Pattern.compile(MOBILE_PATTERN);
|
|
|
Matcher matcher = pattern.matcher(mobile);
|
|
|
if (matcher.matches()) {
|
|
|
- return ResponseJson.success();
|
|
|
+ return null;
|
|
|
} else {
|
|
|
- return ResponseJson.error("手机号码格式不正确");
|
|
|
+ return "手机号码格式不正确";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -65,106 +60,52 @@ public class ValidateUtil {
|
|
|
/**
|
|
|
* 密码验证
|
|
|
*/
|
|
|
- public static ResponseJson validatePassWord(String password) {
|
|
|
+ public static String validatePassWord(String password) {
|
|
|
if (StringUtils.isEmpty(password) || StringUtils.isBlank(password)) {
|
|
|
- return ResponseJson.error("密码不可为空");
|
|
|
+ return "密码不可为空";
|
|
|
}
|
|
|
if (password.length() > 16 || password.length() < 8) {
|
|
|
- return ResponseJson.error("密码长度不正确(8-16)");
|
|
|
+ return "密码长度不正确(8-16)";
|
|
|
}
|
|
|
Pattern pattern = Pattern.compile(PASSWORD_PATTERN);
|
|
|
Matcher matcher = pattern.matcher(password);
|
|
|
if (matcher.matches()) {
|
|
|
- return ResponseJson.success();
|
|
|
+ return null;
|
|
|
} else {
|
|
|
- return ResponseJson.error("请输入8-16位字符,需字母数字组合。");
|
|
|
+ return "请输入8-16位字符,需字母数字组合。";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 确认密码验证
|
|
|
- */
|
|
|
- public static ResponseJson validatePassWordConfirm(String password, String passWordConfirm) {
|
|
|
- if (StringUtils.isEmpty(passWordConfirm) || StringUtils.isBlank(passWordConfirm)) {
|
|
|
- return ResponseJson.error("确认密码不可为空");
|
|
|
- }
|
|
|
- if (!password.equals(passWordConfirm)) {
|
|
|
- return ResponseJson.error("确认密码与登录密码不一致");
|
|
|
- }
|
|
|
- return ResponseJson.success();
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 验证机构名称
|
|
|
*/
|
|
|
- public static ResponseJson validateClubName(String name) {
|
|
|
+ public static String validateClubName(String name) {
|
|
|
if (StringUtils.isEmpty(name) || StringUtils.isBlank(name)) {
|
|
|
- return ResponseJson.error("请填写美容机构名称");
|
|
|
+ return "请填写美容机构名称";
|
|
|
} else {
|
|
|
Pattern pattern = Pattern.compile(CLUB_NAME_PATTERN);
|
|
|
Matcher matcher = pattern.matcher(name);
|
|
|
if (matcher.matches()) {
|
|
|
- return ResponseJson.success();
|
|
|
- } else {
|
|
|
- return ResponseJson.error("机构名称格式不正确");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 验证姓名为中文:匹配2-8个中文字或不超过16位的英文
|
|
|
- */
|
|
|
- public static ResponseJson validateUserName(String name) {
|
|
|
- if (StringUtils.isEmpty(name) || StringUtils.isBlank(name) || name.length() < 2) {
|
|
|
- return ResponseJson.error("请输入真实名称");
|
|
|
- } else {
|
|
|
- // 判断中文名
|
|
|
- Pattern pattern = Pattern.compile(USER_CN_NAME_PATTERN);
|
|
|
- Matcher matcher = pattern.matcher(name);
|
|
|
- if (matcher.find()) {
|
|
|
- return ResponseJson.success();
|
|
|
+ return null;
|
|
|
} else {
|
|
|
- // 判断英文名
|
|
|
- pattern = Pattern.compile(USER_EN_NAME_PATTERN);
|
|
|
- matcher = pattern.matcher(name);
|
|
|
- if (matcher.matches()) {
|
|
|
- return ResponseJson.success();
|
|
|
- } else {
|
|
|
- return ResponseJson.error("名称格式不正确");
|
|
|
- }
|
|
|
+ return "机构名称格式不正确";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 验证地址格式:长度不超过50
|
|
|
- *
|
|
|
- * @param address
|
|
|
- * @return JsonForm验证信息
|
|
|
- */
|
|
|
- public static ResponseJson validateAddress(String address) {
|
|
|
- if (StringUtils.isEmpty(address) || StringUtils.isBlank(address)) {
|
|
|
- return ResponseJson.error("请输入您的详细街道地址");
|
|
|
- }
|
|
|
- if (address.length() > 50) {
|
|
|
- return ResponseJson.error("地址过长");
|
|
|
- }
|
|
|
- return ResponseJson.success();
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 统一社会信用代码验证
|
|
|
*/
|
|
|
- public static ResponseJson validateSocialCreditCode(String socialCreditCode) {
|
|
|
+ public static String validateSocialCreditCode(String socialCreditCode) {
|
|
|
if (StringUtils.isEmpty(socialCreditCode) || StringUtils.isBlank(socialCreditCode)) {
|
|
|
- return ResponseJson.error("请输入您的统一社会信用代码");
|
|
|
+ return "请输入您的统一社会信用代码";
|
|
|
} else {
|
|
|
Pattern pattern = Pattern.compile(SOCIAL_CREDIT_CODE_PATTERN);
|
|
|
Matcher matcher = pattern.matcher(socialCreditCode);
|
|
|
if (matcher.matches()) {
|
|
|
- return ResponseJson.success();
|
|
|
+ return null;
|
|
|
} else {
|
|
|
- return ResponseJson.error("统一社会信用代码格式不正确");
|
|
|
+ return "统一社会信用代码格式不正确";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -176,8 +117,8 @@ public class ValidateUtil {
|
|
|
* 名称(或联系人姓名)4个字话,显示前两个字和后一个字,中间的用一个星号*表示
|
|
|
* 名称(或联系人姓名)5个字及以上的话,显示前两个字和后一个字,中间的统一用3个星号*表示
|
|
|
*
|
|
|
- * @param name
|
|
|
- * @returnString
|
|
|
+ * @param name
|
|
|
+ * @return String
|
|
|
*/
|
|
|
public static String nameConversion(String name){
|
|
|
char[] nameArr = name.toCharArray();
|