修复bug #789
This commit is contained in:
@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.pictc.constant.FieldNameConstants;
|
||||||
import com.pictc.datalog.DataOperationContent;
|
import com.pictc.datalog.DataOperationContent;
|
||||||
import com.pictc.datalog.DataOperationListener;
|
import com.pictc.datalog.DataOperationListener;
|
||||||
import com.pictc.enums.BusinessCode;
|
import com.pictc.enums.BusinessCode;
|
||||||
@ -129,17 +130,18 @@ public class CountryRegionController {
|
|||||||
}else {
|
}else {
|
||||||
dto.setFullPath(dto.getFullName());
|
dto.setFullPath(dto.getFullName());
|
||||||
}
|
}
|
||||||
|
checkParams(dto);
|
||||||
return content.getObj();
|
return content.getObj();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UpdateLngBRegionDto after(DataOperationContent<UpdateLngBRegionDto> content) {
|
public UpdateLngBRegionDto after(DataOperationContent<UpdateLngBRegionDto> content) {
|
||||||
String msg = CommonCallUtils.saveAfter(content.getTableName(),content.getIdValue());
|
String msg = CommonCallUtils.saveAfter(content.getTableName(),content.getIdValue());
|
||||||
if (StringUtils.isNotBlank(msg)) {
|
if (StringUtils.isNotBlank(msg)) {
|
||||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg));
|
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg));
|
||||||
}
|
}
|
||||||
UpdateLngBRegionDto obj = content.getObj();
|
UpdateLngBRegionDto obj = content.getObj();
|
||||||
tranProvider.saveData(obj.getCode(), obj.getFullName());
|
tranProvider.saveData(obj.getCode(), obj.getFullName());
|
||||||
return content.getObj();
|
return content.getObj();
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
@ -164,15 +166,16 @@ public class CountryRegionController {
|
|||||||
}else {
|
}else {
|
||||||
dto.setFullPath(dto.getFullName());
|
dto.setFullPath(dto.getFullName());
|
||||||
}
|
}
|
||||||
|
checkParams(dto);
|
||||||
return content.getObj();
|
return content.getObj();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UpdateLngBRegionDto after(DataOperationContent<UpdateLngBRegionDto> content) {
|
public UpdateLngBRegionDto after(DataOperationContent<UpdateLngBRegionDto> content) {
|
||||||
String msg = CommonCallUtils.saveAfter(content.getTableName(),content.getIdValue());
|
String msg = CommonCallUtils.saveAfter(content.getTableName(),content.getIdValue());
|
||||||
if (StringUtils.isNotBlank(msg)) {
|
if (StringUtils.isNotBlank(msg)) {
|
||||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg));
|
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg));
|
||||||
}
|
}
|
||||||
UpdateLngBRegionDto obj = content.getObj();
|
UpdateLngBRegionDto obj = content.getObj();
|
||||||
tranProvider.saveData(obj.getCode(), obj.getFullName());
|
tranProvider.saveData(obj.getCode(), obj.getFullName());
|
||||||
return content.getObj();
|
return content.getObj();
|
||||||
@ -241,6 +244,22 @@ public class CountryRegionController {
|
|||||||
return R.ok(countryRegionService.getParentByCode(code,excludeType,startPCode));
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user