Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
@@ -47,6 +47,7 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode MATERIAL_PROPERTIES_NOT_EXISTS = new ErrorCode(1_027_101_001, "物料属性不存在");
|
||||
ErrorCode MATERIAL_HAS_PROPERTIES_NOT_EXISTS = new ErrorCode(1_027_101_002, "物料持有属性不存在");
|
||||
ErrorCode MATERIAL_CLASSES_NOT_EXISTS = new ErrorCode(1_027_101_003, "物料分类不存在");
|
||||
ErrorCode DEPARTMENT_MATERIAL_EXISTS = new ErrorCode(1_027_101_004, "组织物料已存在");
|
||||
ErrorCode DEPARTMENT_MATERIAL_NOT_EXISTS = new ErrorCode(1_027_101_004, "组织物料不存在");
|
||||
ErrorCode MATERIAL_HAS_CLASSES_NOT_EXISTS = new ErrorCode(1_027_101_004, "物料持有属性不存在");
|
||||
ErrorCode MATERIAL_HAS_PROPERTIES_CODE_DUPLICATE = new ErrorCode(1_027_101_106, "同一物料下该属性编码已存在");
|
||||
|
||||
@@ -31,4 +31,13 @@ public interface DepartmentMaterialMapper extends BaseMapperX<DepartmentMaterial
|
||||
.orderByDesc(DepartmentMaterialDO::getId));
|
||||
}
|
||||
|
||||
default Long countExist(DepartmentMaterialDO reqVO) {
|
||||
return selectCount(new LambdaQueryWrapperX<DepartmentMaterialDO>()
|
||||
.eqIfPresent(DepartmentMaterialDO::getInfomationId, reqVO.getInfomationId())
|
||||
.eqIfPresent(DepartmentMaterialDO::getClassesId, reqVO.getClassesId())
|
||||
.eqIfPresent(DepartmentMaterialDO::getDeptId, reqVO.getDeptId())
|
||||
.eqIfPresent(DepartmentMaterialDO::getDictionaryDataValue, reqVO.getDictionaryDataValue())
|
||||
.neIfPresent(DepartmentMaterialDO::getId,reqVO.getId())); // 更新时判断要排除自身
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import com.zt.plat.module.base.dal.dataobject.materialproperties.MaterialPropert
|
||||
import com.zt.plat.module.base.service.masterdatasync.support.MasterDataPropertyDefinition;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.*;
|
||||
@@ -69,6 +70,7 @@ public class DepartmentMaterialServiceImpl implements DepartmentMaterialService
|
||||
public DepartmentMaterialRespVO createDepartmentMaterial(DepartmentMaterialSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
DepartmentMaterialDO departmentMaterial = BeanUtils.toBean(createReqVO, DepartmentMaterialDO.class);
|
||||
validateNotExists(departmentMaterial); // 简单验证不存在相同分类物料
|
||||
departmentMaterialMapper.insert(departmentMaterial);
|
||||
// 构造完整响应,方便前端直接刷新数据
|
||||
return CollUtil.getFirst(decorateDepartmentMaterials(Collections.singletonList(departmentMaterial)));
|
||||
@@ -80,6 +82,7 @@ public class DepartmentMaterialServiceImpl implements DepartmentMaterialService
|
||||
validateDepartmentMaterialExists(updateReqVO.getId());
|
||||
// 更新
|
||||
DepartmentMaterialDO updateObj = BeanUtils.toBean(updateReqVO, DepartmentMaterialDO.class);
|
||||
validateNotExists(updateObj); // 简单验证不存在重复相同分类物料
|
||||
departmentMaterialMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@@ -106,6 +109,14 @@ public class DepartmentMaterialServiceImpl implements DepartmentMaterialService
|
||||
}
|
||||
}
|
||||
|
||||
public void validateNotExists(DepartmentMaterialDO departmentMaterial) {
|
||||
Long cnt = departmentMaterialMapper.countExist(departmentMaterial);
|
||||
if (cnt != null && cnt > 0) {
|
||||
// 已存在未删除的同一条
|
||||
throw exception(DEPARTMENT_MATERIAL_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateDepartmentMaterialExists(Long id) {
|
||||
if (departmentMaterialMapper.selectById(id) == null) {
|
||||
throw exception(DEPARTMENT_MATERIAL_NOT_EXISTS);
|
||||
|
||||
Reference in New Issue
Block a user