|
@@ -44,6 +44,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
|
|
+import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -357,33 +358,64 @@ public class FactoryServiceImpl implements FactoryService {
|
|
if (StringUtils.isBlank(factoryProperty.getFactoryName())) {
|
|
if (StringUtils.isBlank(factoryProperty.getFactoryName())) {
|
|
errorMessage.append("供应商名称").append("为空,");
|
|
errorMessage.append("供应商名称").append("为空,");
|
|
}
|
|
}
|
|
- if (StringUtils.isBlank(factoryProperty.getFactoryType())) {
|
|
|
|
|
|
+ if (StringUtils.isNotBlank(factoryProperty.getFactoryType())) {
|
|
|
|
+ if(FactoryTypeEnum.getCode(factoryProperty.getFactoryType()) == null){
|
|
|
|
+ errorMessage.append("供应商类型").append("枚举值不正确,");
|
|
|
|
+ }else {
|
|
|
|
+ if (!FactoryTypeEnum.BEER.is(FactoryTypeEnum.getCode(factoryProperty.getFactoryType()))) {
|
|
|
|
+ if (StringUtils.isBlank(factoryProperty.getEmail())) {
|
|
|
|
+ errorMessage.append("邮箱").append("为空,");
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isBlank(factoryProperty.getProvince())) {
|
|
|
|
+ errorMessage.append("省").append("为空,");
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isBlank(factoryProperty.getCity())) {
|
|
|
|
+ errorMessage.append("市").append("为空,");
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isBlank(factoryProperty.getDistrict())) {
|
|
|
|
+ errorMessage.append("区").append("为空,");
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isBlank(factoryProperty.getAddress())) {
|
|
|
|
+ errorMessage.append("详细地址").append("为空,");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (FactoryTypeEnum.TWO_COVER.is(FactoryTypeEnum.getCode(factoryProperty.getFactoryType()))) {
|
|
|
|
+ if (StringUtils.isBlank(factoryProperty.getKeymanName())) {
|
|
|
|
+ errorMessage.append("联系人姓名").append("为空,");
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isBlank(factoryProperty.getKeymanMobile())) {
|
|
|
|
+ errorMessage.append("联系人手机号").append("为空,");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
errorMessage.append("供应商类型").append("为空,");
|
|
errorMessage.append("供应商类型").append("为空,");
|
|
}
|
|
}
|
|
- if (StringUtils.isNotBlank(factoryProperty.getFactoryType())
|
|
|
|
- && FactoryTypeEnum.getCode(factoryProperty.getFactoryType()) == null) {
|
|
|
|
- errorMessage.append("供应商类型").append("枚举值不正确,");
|
|
|
|
- }
|
|
|
|
- if (StringUtils.isNotBlank(factoryProperty.getIsFirstFactory())
|
|
|
|
- && FirstFactoryEnum.getCode(factoryProperty.getIsFirstFactory()) == null) {
|
|
|
|
- errorMessage.append("是否一级供应商").append("枚举值不正确,");
|
|
|
|
- }
|
|
|
|
- if (StringUtils.isBlank(factoryProperty.getKeymanName())) {
|
|
|
|
- errorMessage.append("联系人姓名").append("为空,");
|
|
|
|
- }
|
|
|
|
- if (StringUtils.isBlank(factoryProperty.getKeymanMobile())) {
|
|
|
|
- errorMessage.append("联系人手机号").append("为空,");
|
|
|
|
- }
|
|
|
|
- Pattern patternPhone = Pattern.compile("^[1]\\d{10}$");
|
|
|
|
- if(!patternPhone.matcher(factoryProperty.getKeymanMobile()).matches()){
|
|
|
|
- errorMessage.append("联系人手机号").append("格式不正确,");
|
|
|
|
|
|
+ if (StringUtils.isNotBlank(factoryProperty.getIsFirstFactory())) {
|
|
|
|
+ if(FirstFactoryEnum.getCode(factoryProperty.getIsFirstFactory()) == null){
|
|
|
|
+ errorMessage.append("是否一级供应商").append("枚举值不正确,");
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ if (StringUtils.isNotBlank(factoryProperty.getFactoryType())
|
|
|
|
+ && FactoryTypeEnum.COVER.is(FactoryTypeEnum.getCode(factoryProperty.getFactoryType()))){
|
|
|
|
+ errorMessage.append("是否一级供应商").append("为空,");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- if (StringUtils.isBlank(factoryProperty.getEmail())) {
|
|
|
|
- errorMessage.append("邮箱").append("为空,");
|
|
|
|
|
|
+ //验证手机号
|
|
|
|
+ if (StringUtils.isNotBlank(factoryProperty.getKeymanMobile())){
|
|
|
|
+ Pattern keymanMobileFormat = Pattern.compile("^1[0-9]{10}$");
|
|
|
|
+ Matcher matcher = keymanMobileFormat.matcher(factoryProperty.getKeymanMobile());
|
|
|
|
+ if (!matcher.matches()){
|
|
|
|
+ errorMessage.append("联系人手机号").append("格式不正确,");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- Pattern patternEmail = Pattern.compile("^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$");
|
|
|
|
- if(!patternEmail.matcher(factoryProperty.getEmail()).matches()){
|
|
|
|
- errorMessage.append("邮箱").append("格式不正确,");
|
|
|
|
|
|
+ //验证邮箱
|
|
|
|
+ if (StringUtils.isNotBlank(factoryProperty.getEmail())) {
|
|
|
|
+ Pattern emailFormat = Pattern.compile("^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$");
|
|
|
|
+ Matcher matcher = emailFormat.matcher(factoryProperty.getEmail());
|
|
|
|
+ if (!matcher.matches()) {
|
|
|
|
+ errorMessage.append("邮箱").append("格式不正确,");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
return errorMessage.toString();
|
|
return errorMessage.toString();
|