This commit is contained in:
2025-12-22 17:48:07 +08:00
parent 4b1a419c23
commit f7c42d494f

View File

@ -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<UpdateLngBRegionDto> 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<UpdateLngBRegionDto> 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<LngBRegion>()
.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<LngBRegion>()
.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));
}
}
}