diff --git a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/controller/CountryRegionController.java b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/controller/CountryRegionController.java index 8870303..1dc6b4c 100644 --- a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/controller/CountryRegionController.java +++ b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/controller/CountryRegionController.java @@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RestController; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.pictc.constant.FieldNameConstants; import com.pictc.datalog.DataOperationContent; import com.pictc.datalog.DataOperationListener; import com.pictc.enums.BusinessCode; @@ -129,17 +130,18 @@ public class CountryRegionController { }else { dto.setFullPath(dto.getFullName()); } + checkParams(dto); return content.getObj(); } @Override public UpdateLngBRegionDto after(DataOperationContent content) { String msg = CommonCallUtils.saveAfter(content.getTableName(),content.getIdValue()); - if (StringUtils.isNotBlank(msg)) { - throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg)); - } - UpdateLngBRegionDto obj = content.getObj(); - tranProvider.saveData(obj.getCode(), obj.getFullName()); + if (StringUtils.isNotBlank(msg)) { + throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg)); + } + UpdateLngBRegionDto obj = content.getObj(); + tranProvider.saveData(obj.getCode(), obj.getFullName()); return content.getObj(); } })); @@ -164,15 +166,16 @@ public class CountryRegionController { }else { dto.setFullPath(dto.getFullName()); } + checkParams(dto); return content.getObj(); } @Override public UpdateLngBRegionDto after(DataOperationContent content) { String msg = CommonCallUtils.saveAfter(content.getTableName(),content.getIdValue()); - if (StringUtils.isNotBlank(msg)) { - throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg)); - } + if (StringUtils.isNotBlank(msg)) { + throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg)); + } UpdateLngBRegionDto obj = content.getObj(); tranProvider.saveData(obj.getCode(), obj.getFullName()); return content.getObj(); @@ -241,6 +244,22 @@ public class CountryRegionController { return R.ok(countryRegionService.getParentByCode(code,excludeType,startPCode)); } + + + private void checkParams(UpdateLngBRegionDto dto) { + Long codeCount = countryRegionService.count(new LambdaQueryWrapper() + .eq(LngBRegion::getCode, dto.getCode()).ne(dto.getId() != null, LngBRegion::getId, dto.getId())); + if (codeCount > 0) { + throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DATA_FIELD_DUPLICATION, + FieldNameConstants.CODE)); + } + Long nameCount = countryRegionService.count(new LambdaQueryWrapper() + .eq(LngBRegion::getFullName, dto.getFullName()).ne(dto.getId() != null, LngBRegion::getId, dto.getId())); + if (nameCount > 0) { + throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DATA_FIELD_DUPLICATION, + FieldNameConstants.FULL_NAME)); + } + } } \ No newline at end of file