From 2d320e926365fda6ed42815473279ead84c3884d Mon Sep 17 00:00:00 2001 From: "t-shunyi.kuang" <846002312@qq.com> Date: Thu, 23 Oct 2025 10:23:33 +0800 Subject: [PATCH] =?UTF-8?q?=E9=93=B6=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/mdm/controller/BankController.java | 2 +- .../controller/CountryRegionController.java | 24 +----- .../module/mdm/service/IBankService.java | 2 + .../mdm/service/ICountryRegionService.java | 4 + .../mdm/service/impl/BankServiceImpl.java | 16 +++- .../impl/CountryRegionServiceImpl.java | 73 +++++++++++++------ 6 files changed, 75 insertions(+), 46 deletions(-) diff --git a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/controller/BankController.java b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/controller/BankController.java index 04fa230..f7e1ebe 100644 --- a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/controller/BankController.java +++ b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/controller/BankController.java @@ -107,7 +107,7 @@ public class BankController { @ApiOperation(value = "修改LngBBank") @SaCheckPermission("bank:edit") public R update(@Valid @RequestBody UpdateLngBBankDto dto){ - return R.ok(dataService.updateById(dto)); + return R.ok(bankService.update(dto)); } @DeleteMapping 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 a33efbf..2bfee53 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 @@ -102,16 +102,7 @@ public class CountryRegionController { @ApiOperation(value = "新增LngBRegion") @SaCheckPermission("countryRegion:add") public R add(@Valid @RequestBody UpdateLngBRegionDto dto){ - if(!CountryRegionEnum.CONTINENT.getCode().equals(dto.getRegionTypeCode()) ) { - if(dto.getPid() != null && dto.getPid() != 0) { - LngBRegion parentRegion = countryRegionService.getById(dto.getPid()); - if(parentRegion != null) { - dto.setFullPath(parentRegion.getFullPath()+dto.getFullName()); - } - } - }else { - dto.setFullPath(dto.getFullName()); - } + Long res = countryRegionService.add(dto); return R.ok(res); } @@ -120,17 +111,8 @@ public class CountryRegionController { @ApiOperation(value = "修改LngBRegion") @SaCheckPermission("countryRegion:edit") public R update(@Valid @RequestBody UpdateLngBRegionDto dto){ - if(!CountryRegionEnum.CONTINENT.getCode().equals(dto.getRegionTypeCode()) ) { - if(dto.getPid() != null && dto.getPid() != 0) { - LngBRegion parentRegion = countryRegionService.getById(dto.getPid()); - if(parentRegion != null) { - dto.setFullPath(parentRegion.getFullPath()+dto.getFullName()); - } - } - }else { - dto.setFullPath(dto.getFullName()); - } - return R.ok(dataService.updateById(dto)); + + return R.ok(countryRegionService.update(dto)); } @DeleteMapping diff --git a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/IBankService.java b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/IBankService.java index 034bbc8..26e2c34 100644 --- a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/IBankService.java +++ b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/IBankService.java @@ -20,4 +20,6 @@ public interface IBankService extends IService { boolean enable(List ids); boolean disable(List ids); + + Long update(UpdateLngBBankDto dto); } diff --git a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/ICountryRegionService.java b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/ICountryRegionService.java index 22dd37e..2e73d8a 100644 --- a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/ICountryRegionService.java +++ b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/ICountryRegionService.java @@ -2,6 +2,8 @@ package com.xjrsoft.module.mdm.service; import java.util.List; +import javax.validation.Valid; + import com.baomidou.mybatisplus.extension.service.IService; import com.xjrsoft.module.mdm.dto.UpdateLngBRegionDto; import com.xjrsoft.module.mdm.entity.LngBRegion; @@ -20,4 +22,6 @@ public interface ICountryRegionService extends IService { boolean enable(List ids); boolean disable(List ids); + + Long update(UpdateLngBRegionDto dto); } diff --git a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/impl/BankServiceImpl.java b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/impl/BankServiceImpl.java index 736f1ee..4fc2c79 100644 --- a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/impl/BankServiceImpl.java +++ b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/impl/BankServiceImpl.java @@ -18,6 +18,7 @@ import com.xjrsoft.module.common.db.service.CommonCallService; import com.xjrsoft.module.datalog.service.DatalogService; import com.xjrsoft.module.mdm.dto.UpdateLngBBankDto; import com.xjrsoft.module.mdm.entity.LngBBank; +import com.xjrsoft.module.mdm.entity.LngBRegion; import com.xjrsoft.module.mdm.mapper.LngBBankMapper; import com.xjrsoft.module.mdm.service.IBankService; import com.xjrsoft.module.system.client.ICodeRuleClient; @@ -50,6 +51,15 @@ public class BankServiceImpl extends ServiceImpl imple //this.addOrUpdateAfter(res.getId()); return res.getId(); } + + @Override + @Transactional(rollbackFor = Exception.class) + public Long update(UpdateLngBBankDto dto) { + this.checkParams(dto); + UpdateLngBBankDto res = DataLogTools.update(dto); + //this.addOrUpdateAfter(res.getId()); + return res.getId(); + } @Override public boolean enable(List ids) { @@ -59,18 +69,18 @@ public class BankServiceImpl extends ServiceImpl imple @Override public boolean disable(List ids) { - return dataService.disable(UpdateLngBBankDto.class,ids); + return dataService.disable(UpdateLngBBankDto.class,ids); } private void checkParams(UpdateLngBBankDto dto) { Long codeCount = this.baseMapper.selectCount(new LambdaQueryWrapper() - .eq(LngBBank::getCode, dto.getCode())); + .eq(LngBBank::getCode, dto.getCode()).ne(dto.getId() != null, LngBBank::getId, dto.getId())); if (codeCount > 0) { throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DATA_FIELD_DUPLICATION, FieldNameConstants.CODE)); } Long nameCount = this.baseMapper.selectCount(new LambdaQueryWrapper() - .eq(LngBBank::getFullName, dto.getFullName())); + .eq(LngBBank::getFullName, dto.getFullName()).ne(dto.getId() != null, LngBBank::getId, dto.getId())); if (nameCount > 0) { throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DATA_FIELD_DUPLICATION, FieldNameConstants.FULL_NAME)); diff --git a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/impl/CountryRegionServiceImpl.java b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/impl/CountryRegionServiceImpl.java index 54259f5..d9ceede 100644 --- a/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/impl/CountryRegionServiceImpl.java +++ b/itc-pcitc-mdm/itc-pcitc-mdm-service/src/main/java/com/xjrsoft/module/mdm/service/impl/CountryRegionServiceImpl.java @@ -18,6 +18,7 @@ import com.xjrsoft.module.common.db.service.CommonCallService; import com.xjrsoft.module.datalog.service.DatalogService; import com.xjrsoft.module.mdm.dto.UpdateLngBRegionDto; import com.xjrsoft.module.mdm.entity.LngBRegion; +import com.xjrsoft.module.mdm.enums.CountryRegionEnum; import com.xjrsoft.module.mdm.mapper.LngBRegionMapper; import com.xjrsoft.module.mdm.service.ICountryRegionService; @@ -40,6 +41,16 @@ public class CountryRegionServiceImpl extends ServiceImpl ids) { - return dataService.disable(UpdateLngBRegionDto.class,ids); + return dataService.disable(UpdateLngBRegionDto.class,ids); } - private void checkParams(UpdateLngBRegionDto dto) { - Long codeCount = this.baseMapper.selectCount(new LambdaQueryWrapper() - .eq(LngBRegion::getCode, dto.getCode())); - if (codeCount > 0) { - throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DATA_FIELD_DUPLICATION, - FieldNameConstants.CODE)); - } - Long nameCount = this.baseMapper.selectCount(new LambdaQueryWrapper() - .eq(LngBRegion::getFullName, dto.getFullName())); - if (nameCount > 0) { - throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DATA_FIELD_DUPLICATION, - FieldNameConstants.FULL_NAME)); - } - } + - private void addOrUpdateAfter(Long id) { - String msg = commonCallService.saveAfter(TableNameConstants.LNG_B_REGION, id); - if (StringUtils.isNotBlank(msg)) { - throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg)); - } - } + @Override + public Long update(UpdateLngBRegionDto dto) { + if(!CountryRegionEnum.CONTINENT.getCode().equals(dto.getRegionTypeCode()) ) { + if(dto.getPid() != null && dto.getPid() != 0) { + LngBRegion parentRegion = this.getById(dto.getPid()); + if(parentRegion != null) { + dto.setFullPath(parentRegion.getFullPath()+dto.getFullName()); + } + } + }else { + dto.setFullPath(dto.getFullName()); + } + this.checkParams(dto); + UpdateLngBRegionDto res = DataLogTools.update(dto); + //this.addOrUpdateAfter(res.getId()); + return res.getId(); + } + + private void checkParams(UpdateLngBRegionDto dto) { + Long codeCount = this.baseMapper.selectCount(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 = this.baseMapper.selectCount(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)); + } + } + + private void addOrUpdateAfter(Long id) { + String msg = commonCallService.saveAfter(TableNameConstants.LNG_B_REGION, id); + if (StringUtils.isNotBlank(msg)) { + throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg)); + } + } }