银行管理调用数据库函数

This commit is contained in:
2025-10-23 13:42:34 +08:00
parent f9b9b2bbd2
commit 7628a0ca47
6 changed files with 86 additions and 9 deletions

View File

@ -21,4 +21,9 @@ public interface FieldNameConstants {
* 本币
*/
String LOCAL_SIGN = "本币";
/**
* 简称
*/
String SHORT_NAME = "简称名称";
}

View File

@ -65,5 +65,11 @@ public class LngBBankPageVo {
*/
@ApiModelProperty("数据权限id")
private Long ruleUserId;
/**
* 所属国家和地区
*/
@ApiModelProperty("所属国家和地区名称")
private String regionName;
}

View File

@ -26,12 +26,15 @@ import com.xjrsoft.module.datalog.vo.DataChangeLogVo;
import com.xjrsoft.module.mdm.dto.LngBBankPageDto;
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.service.IBankService;
import com.xjrsoft.module.mdm.service.ICountryRegionService;
import com.xjrsoft.module.mdm.vo.LngBBankPageVo;
import com.xjrsoft.module.mdm.vo.LngBBankVo;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -52,6 +55,8 @@ public class BankController {
private final IBankService bankService;
private final DatalogService dataService;
private final ICountryRegionService regionService;
@GetMapping(value = "/page")
@ApiOperation(value="LngBBank列表(分页)")
@ -71,10 +76,15 @@ public class BankController {
.select(LngBBank.class,x -> VoToColumnUtil.fieldsToColumns(LngBBankPageVo.class).contains(x.getProperty()));
IPage<LngBBank> page = bankService.page(ConventPage.getPage(dto), queryWrapper);
PageOutput<LngBBankPageVo> pageOutput = ConventPage.getPageOutput(page, LngBBankPageVo.class);
List<LngBBankPageVo> list = pageOutput.getList();
setRegionName(list);
return R.ok(pageOutput);
}
@GetMapping(value = "/info")
@GetMapping(value = "/info")
@ApiOperation(value="根据id查询LngBBank信息")
@SaCheckPermission("bank:detail")
public R info(@RequestParam Long id){
@ -147,4 +157,24 @@ public class BankController {
public R disable(@Valid @RequestBody List<Long> ids){
return R.ok(bankService.disable(ids));
}
private void setRegionName(List<LngBBankPageVo> list) {
if(CollectionUtil.isNotEmpty(list)) {
for(LngBBankPageVo vo: list) {
if(StrUtil.isNotBlank(vo.getRegionCode())) {
String[] regionArr = vo.getRegionCode().split(",");
if(regionArr != null && regionArr.length > 0) {
String lastRegionCode = regionArr[regionArr.length-1];
LambdaQueryWrapper<LngBRegion> regionQueryWrapper = new LambdaQueryWrapper<>();
regionQueryWrapper.eq(LngBRegion::getCode, lastRegionCode);
LngBRegion lastRegion = regionService.getOne(regionQueryWrapper);
if(lastRegion != null) {
vo.setRegionName(lastRegion.getFullName());
}
}
}
}
}
}
}

View File

@ -155,6 +155,7 @@ public class CountryRegionController {
@SaCheckPermission("countryRegion:enable")
public R enable(@Valid @RequestBody List<Long> ids){
return R.ok(countryRegionService.enable(ids));
}

View File

@ -18,7 +18,6 @@ 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;
@ -41,14 +40,16 @@ public class BankServiceImpl extends ServiceImpl<LngBBankMapper, LngBBank> imple
private final ICodeRuleClient codeRuleClient;
private final String BANKCODE = "bankCode";
@Override
@Transactional(rollbackFor = Exception.class)
public Long add(UpdateLngBBankDto dto) {
String code = codeRuleClient.genEncode("bankCode");
String code = codeRuleClient.genEncode(BANKCODE);
dto.setCode(code);
this.checkParams(dto);
UpdateLngBBankDto res = DataLogTools.insert(dto);
//this.addOrUpdateAfter(res.getId());
this.addOrUpdateAfter(res.getId());
return res.getId();
}
@ -57,19 +58,33 @@ public class BankServiceImpl extends ServiceImpl<LngBBankMapper, LngBBank> imple
public Long update(UpdateLngBBankDto dto) {
this.checkParams(dto);
UpdateLngBBankDto res = DataLogTools.update(dto);
//this.addOrUpdateAfter(res.getId());
this.addOrUpdateAfter(res.getId());
return res.getId();
}
@Override
public boolean enable(List<Long> ids) {
return dataService.disable(UpdateLngBBankDto.class,ids);
dataService.disable(UpdateLngBBankDto.class,ids);
for (Long id : ids) {
String msg = commonCallService.enableBefore(TableNameConstants.LNG_B_PRICE_TERM, id);
if (StringUtils.isNotBlank(msg)) {
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg));
}
}
return true;
}
@Override
public boolean disable(List<Long> ids) {
return dataService.disable(UpdateLngBBankDto.class,ids);
dataService.disable(UpdateLngBBankDto.class,ids);
for (Long id : ids) {
String msg = commonCallService.enableBefore(TableNameConstants.LNG_B_PRICE_TERM, id);
if (StringUtils.isNotBlank(msg)) {
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg));
}
}
return true;
}
private void checkParams(UpdateLngBBankDto dto) {
@ -79,6 +94,12 @@ public class BankServiceImpl extends ServiceImpl<LngBBankMapper, LngBBank> imple
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DATA_FIELD_DUPLICATION,
FieldNameConstants.CODE));
}
Long shortNameCount = this.baseMapper.selectCount(new LambdaQueryWrapper<LngBBank>()
.eq(LngBBank::getShortName, dto.getShortName()).ne(dto.getId() != null, LngBBank::getId, dto.getId()));
if (shortNameCount > 0) {
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DATA_FIELD_DUPLICATION,
FieldNameConstants.SHORT_NAME));
}
Long nameCount = this.baseMapper.selectCount(new LambdaQueryWrapper<LngBBank>()
.eq(LngBBank::getFullName, dto.getFullName()).ne(dto.getId() != null, LngBBank::getId, dto.getId()));
if (nameCount > 0) {

View File

@ -59,13 +59,27 @@ public class CountryRegionServiceImpl extends ServiceImpl<LngBRegionMapper, LngB
@Override
public boolean enable(List<Long> ids) {
return dataService.disable(UpdateLngBRegionDto.class,ids);
dataService.disable(UpdateLngBRegionDto.class,ids);
for (Long id : ids) {
String msg = commonCallService.enableBefore(TableNameConstants.LNG_B_PRICE_TERM, id);
if (StringUtils.isNotBlank(msg)) {
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg));
}
}
return true;
}
@Override
public boolean disable(List<Long> ids) {
return dataService.disable(UpdateLngBRegionDto.class,ids);
dataService.disable(UpdateLngBRegionDto.class,ids);
for (Long id : ids) {
String msg = commonCallService.enableBefore(TableNameConstants.LNG_B_PRICE_TERM, id);
if (StringUtils.isNotBlank(msg)) {
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg));
}
}
return true;
}