fix: 修复删除时根节点无下级导致sql异常的问题

This commit is contained in:
曹鹏飞 2024-04-29 08:38:17 +08:00
parent 8634cffaf7
commit dcc5f031b2
1 changed files with 7 additions and 3 deletions

View File

@ -304,7 +304,7 @@ public class DQBomService {
public void deleteBom(Long rowId) { public void deleteBom(Long rowId) {
BomNewDQbomParentEntity root = dQBomParentService.getById(rowId); BomNewDQbomParentEntity root = dQBomParentService.getById(rowId);
VUtils.isTure(Objects.isNull(root)).throwMessage("bom不存在"); VUtils.isTure(Objects.isNull(root)).throwMessage("bom不存在");
VUtils.isTure(!SessionUtil.getUserCode().equals(root.getCreatedBy())).throwMessage("不能删除他人创建的bom"); // VUtils.isTure(!SessionUtil.getUserCode().equals(root.getCreatedBy())).throwMessage("不能删除他人创建的bom");
VUtils.isTure(root.getStatus().equals(DQBomStatusEnum.PUBLISHED.getValue())).throwMessage("不能删除已发布的bom"); VUtils.isTure(root.getStatus().equals(DQBomStatusEnum.PUBLISHED.getValue())).throwMessage("不能删除已发布的bom");
Set<Long> liChildren = new HashSet<>(); Set<Long> liChildren = new HashSet<>();
@ -314,8 +314,12 @@ public class DQBomService {
children.forEach(c -> { children.forEach(c -> {
delete(liParents, liChildren, c); delete(liParents, liChildren, c);
}); });
dQBomParentService.getBaseMapper().deleteBatchIds(liParents); if (CollUtil.isNotEmpty(liParents)) {
dQBomChildService.getBaseMapper().deleteBatchIds(liChildren); dQBomParentService.getBaseMapper().deleteBatchIds(liParents);
}
if (CollUtil.isNotEmpty(liChildren)) {
dQBomChildService.getBaseMapper().deleteBatchIds(liChildren);
}
} }
private void delete(Set<Long> parents, Set<Long> children, BomNewDQbomVO bom) { private void delete(Set<Long> parents, Set<Long> children, BomNewDQbomVO bom) {