xushengqiang 6 lat temu
rodzic
commit
27f78564ea

+ 1 - 1
efunbox-base/efunbox-base-api/src/main/java/cn/efunbox/manage/base/service/impl/CostTypeServiceImpl.java

@@ -57,7 +57,7 @@ public class CostTypeServiceImpl implements CostTypeService {
             return ApiResult.error(ApiCode.PARAMETER_ERROR);
         }
         CostType oldCostType = costTypeRepository.findByName(costType.getName());
-        if(!Objects.equals(oldCostType.getId(), costType.getId())){
+        if(Objects.nonNull(oldCostType) && !Objects.equals(oldCostType.getId(), costType.getId())){
             return ApiResult.error(ApiCode.REPETITION_ERROR);
         }
         costType = costTypeRepository.update(costType);

+ 1 - 1
efunbox-base/efunbox-base-api/src/main/java/cn/efunbox/manage/base/service/impl/DepartmentServiceImpl.java

@@ -58,7 +58,7 @@ public class DepartmentServiceImpl implements DepartmentService {
             return ApiResult.error(ApiCode.PARAMETER_ERROR);
         }
         Department oldDepartment = departmentRepository.findByName(department.getName());
-        if(!Objects.equals(oldDepartment.getId(), department.getId())){
+        if(Objects.nonNull(oldDepartment) && !Objects.equals(oldDepartment.getId(), department.getId())){
             return ApiResult.error(ApiCode.REPETITION_ERROR);
         }
         department = departmentRepository.update(department);

+ 1 - 1
efunbox-base/efunbox-base-api/src/main/java/cn/efunbox/manage/base/service/impl/ProductServiceImpl.java

@@ -62,7 +62,7 @@ public class ProductServiceImpl implements ProductService {
             return ApiResult.error(ApiCode.PARAMETER_ERROR);
         }
         Product oldProduct = productRepository.findByName(product.getName());
-        if(!Objects.equals(oldProduct.getId(), product.getId())){
+        if(Objects.nonNull(oldProduct) && !Objects.equals(oldProduct.getId(), product.getId())){
             return ApiResult.error(ApiCode.REPETITION_ERROR);
         }
         product = productRepository.update(product);

+ 1 - 1
efunbox-base/efunbox-base-api/src/main/java/cn/efunbox/manage/base/service/impl/ProjectServiceImpl.java

@@ -61,7 +61,7 @@ public class ProjectServiceImpl implements ProjectService {
             return ApiResult.error(ApiCode.PARAMETER_ERROR);
         }
         Project oldProject = projectRepository.findByName(project.getName());
-        if(!Objects.equals(oldProject.getId(), project.getId())){
+        if(Objects.nonNull(oldProject) && !Objects.equals(oldProject.getId(), project.getId())){
             return ApiResult.error(ApiCode.REPETITION_ERROR);
         }
         project = projectRepository.update(project);