|
@@ -81,7 +81,7 @@ public class FactoryServiceImpl implements FactoryService {
|
|
|
//code不能重复
|
|
|
QueryWrapper<BaseFactory> factoryQw = new QueryWrapper<>();
|
|
|
factoryQw.eq("factory_code", req.getFactoryCode());
|
|
|
- factoryQw.eq("is_delete",0);
|
|
|
+ factoryQw.eq("is_delete", 0);
|
|
|
if (req.getId() != null) {
|
|
|
factoryQw.ne("id", req.getId());
|
|
|
}
|
|
@@ -89,16 +89,6 @@ public class FactoryServiceImpl implements FactoryService {
|
|
|
if (CollectionUtil.isNotEmpty(checkFactoryList)) {
|
|
|
throw new BusinessException(ErrorCodeEnum.ERROR_PARAM.getCode(), "供应商ID已存在");
|
|
|
}
|
|
|
- //判断供应商名称是否存在
|
|
|
- if (req.getFactoryName() != null) {
|
|
|
- QueryWrapper<BaseFactory> qw = new QueryWrapper<>();
|
|
|
- qw.eq("factory_name", req.getFactoryName());
|
|
|
- qw.eq("is_delete",0);
|
|
|
- List<BaseFactory> checkNameList = baseFactoryMapper.selectList(qw);
|
|
|
- if (CollectionUtil.isNotEmpty(checkNameList)) {
|
|
|
- throw new BusinessException(ErrorCodeEnum.ERROR_PARAM.getCode(), "供应商名称已存在");
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
//1-声明对象
|
|
|
BaseFactory factory = null;
|
|
@@ -130,8 +120,18 @@ public class FactoryServiceImpl implements FactoryService {
|
|
|
|
|
|
//3-新增or修改
|
|
|
if (req.getId() != null) {
|
|
|
+ //判断供应商名称是否存在
|
|
|
+ BaseFactory checkFactoryName = checkFactoryName(factory.getFactoryName());
|
|
|
+ if (!checkFactoryName.getId().equals(req.getId())) {
|
|
|
+ throw new BusinessException(ErrorCodeEnum.ERROR_PARAM.getCode(), "供应商名称已存在");
|
|
|
+ }
|
|
|
baseFactoryMapper.updateById(factory);
|
|
|
} else {
|
|
|
+ //判断供应商名称是否存在
|
|
|
+ BaseFactory baseFactory = checkFactoryName(factory.getFactoryName());
|
|
|
+ if (Objects.nonNull(baseFactory)) {
|
|
|
+ throw new BusinessException(ErrorCodeEnum.ERROR_PARAM.getCode(), "供应商名称已存在");
|
|
|
+ }
|
|
|
baseFactoryMapper.insert(factory);
|
|
|
}
|
|
|
|
|
@@ -375,14 +375,14 @@ public class FactoryServiceImpl implements FactoryService {
|
|
|
errorMessage.append("联系人手机号").append("为空,");
|
|
|
}
|
|
|
Pattern patternPhone = Pattern.compile("^[1]\\d{10}$");
|
|
|
- if(!patternPhone.matcher(factoryProperty.getKeymanMobile()).matches()){
|
|
|
+ if (!patternPhone.matcher(factoryProperty.getKeymanMobile()).matches()) {
|
|
|
errorMessage.append("联系人手机号").append("格式不正确,");
|
|
|
}
|
|
|
if (StringUtils.isBlank(factoryProperty.getEmail())) {
|
|
|
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()){
|
|
|
+ if (!patternEmail.matcher(factoryProperty.getEmail()).matches()) {
|
|
|
errorMessage.append("邮箱").append("格式不正确,");
|
|
|
}
|
|
|
|
|
@@ -407,6 +407,16 @@ public class FactoryServiceImpl implements FactoryService {
|
|
|
return factory;
|
|
|
}
|
|
|
|
|
|
+ private BaseFactory checkFactoryName(String factoryName) {
|
|
|
+
|
|
|
+ QueryWrapper<BaseFactory> qw = new QueryWrapper<>();
|
|
|
+ qw.eq("factory_name", factoryName);
|
|
|
+ qw.eq("is_delete", 0);
|
|
|
+ BaseFactory baseFactory = baseFactoryMapper.selectOne(qw);
|
|
|
+
|
|
|
+ return baseFactory;
|
|
|
+ }
|
|
|
+
|
|
|
// 6.03已废弃
|
|
|
// @Override
|
|
|
// public ListFactorySelectRes listPackageFactorySelect(ListFactorySelectReq req) {
|