Browse Source

删除二级分类时,校验是否存在套题

master
luogw 1 month ago
parent
commit
6c69a76ac5
  1. 8
      src/main/java/com/project/classicpaper/application/impl/ClassicCategoryApplicationServiceImpl.java

8
src/main/java/com/project/classicpaper/application/impl/ClassicCategoryApplicationServiceImpl.java

@ -257,6 +257,14 @@ public class ClassicCategoryApplicationServiceImpl implements ClassicCategoryApp
throw new BusinessErrorException("该分类下存在子分类,无法删除"); throw new BusinessErrorException("该分类下存在子分类,无法删除");
} }
} }
// 如果是二级分类,校验是否存在套题
if (Objects.equals(category.getLevel(), 2)) {
long paperSetCount = classicPaperSetBaseService.count(
new LambdaQueryWrapper<ClassicPaperSetEntity>().eq(ClassicPaperSetEntity::getClassicCategoryId, id));
if (paperSetCount > 0) {
throw new BusinessErrorException("该分类下存在套题,无法删除");
}
}
classicCategoryBaseService.removeById(id); classicCategoryBaseService.removeById(id);
return Result.success("删除成功"); return Result.success("删除成功");
} }

Loading…
Cancel
Save