diff --git a/src/main/java/com/huoran/iasf/controller/SysColumnController.java b/src/main/java/com/huoran/iasf/controller/SysColumnController.java index 49bf526..84c237b 100644 --- a/src/main/java/com/huoran/iasf/controller/SysColumnController.java +++ b/src/main/java/com/huoran/iasf/controller/SysColumnController.java @@ -133,22 +133,34 @@ public class SysColumnController { @PostMapping("/batchDeletion") @ApiOperation(value = "批量删除栏目", response = SysColumn.class) public R batchDeletion(@ApiParam(name = "ids", value = "主键", required = true) @RequestParam List ids) { + boolean ret = false; for (Integer id : ids) { UpdateWrapper filesEntityUpdateWrapper = new UpdateWrapper<>(); filesEntityUpdateWrapper.eq("quote_id", id); filesEntityUpdateWrapper.eq("quote_type", 1); filesEntityUpdateWrapper.set("is_del", 1); sysFilesService.update(filesEntityUpdateWrapper); + //1 创建list集合,用于封装所有删除菜单id值 + List idList = new ArrayList<>(); + //2 向idList集合设置删除菜单id + //找到当前菜单的子菜单 把结果id封装到idlist里面去 + this.selectCategoryChildById(id + "", idList); + //把当前id封装到list里面 //现在把当前id封装进去 之前都是子菜单的id + idList.add(id); + + //删除当前栏目以及栏目下的文章 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.in("column_id", idList); + //删除栏目后删除栏目下的文章 + contentService.remove(queryWrapper); + ret = service.removeByIds(idList); } - boolean delState = service.removeByIds(ids); - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.in("column_id", ids); - //删除栏目后删除栏目下的文章 - contentService.remove(queryWrapper); - return delState ? R.success() : R.fail("删除失败"); + + return R.success(); } + @PostMapping("/sameLevelJudgment") @ApiOperation(value = "同级判重", response = ColumnWeightReqVO.class) public R sameLevelJudgment(@RequestBody @Valid ColumnWeightReqVO sysColumn) { @@ -218,10 +230,13 @@ public class SysColumnController { QueryWrapper wrapper = new QueryWrapper(); wrapper.eq("father_id", id); wrapper.eq("deleted", Constant.DATA_NOT_DELETED); - wrapper.select("id");//我们只想查询id 所以只需要查询指定列的值 - List childIdList = service.list(wrapper);//当前菜单的所有子菜单 + //查询指定列的值 + wrapper.select("id"); + //当前菜单的所有子菜单 + List childIdList = service.list(wrapper); //把childIdList里面菜单id值获取出来,封装idList里面,做递归查询 - childIdList.stream().forEach(item -> {//遍历集合得到每一个对象item + //遍历集合得到每一个对象item + childIdList.stream().forEach(item -> { //封装idList里面 idList.add(item.getId()); //递归查询 @@ -253,8 +268,7 @@ public class SysColumnController { @ApiOperation("某一级查全部") @PostMapping("/oneLevelChecksThemAll") - public R oneLevelChecksThemAll(@ApiParam(name = "id", value = "栏目id", required = true) @RequestParam Integer id, - @ApiParam(name = "isSort", value = "判断是否为排序接口调用(1为排序接口调用 0我栏目管理列表调用)", required = true) @RequestParam Integer isSort) { + public R oneLevelChecksThemAll(@ApiParam(name = "id", value = "栏目id", required = true) @RequestParam Integer id, @ApiParam(name = "isSort", value = "判断是否为排序接口调用(1为排序接口调用 0我栏目管理列表调用)", required = true) @RequestParam Integer isSort) { Integer pid = service.oneLevelChecksThemAll(id); String ids = this.getIds(pid);