From d6b620f94559843186ee485ab640be46c2d748dc Mon Sep 17 00:00:00 2001 From: "rong.liu" Date: Tue, 28 Mar 2023 11:25:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=88=A0=E9=99=A4=E6=A0=8F?= =?UTF-8?q?=E7=9B=AE=E7=9A=84=E5=AF=B9=E5=AD=90=E7=BA=A7=E6=A0=8F=E7=9B=AE?= =?UTF-8?q?=E4=BB=A5=E5=8F=8A=E6=A0=8F=E7=9B=AE=E4=B8=8B=E7=9A=84=E6=96=87?= =?UTF-8?q?=E7=AB=A0=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iasf/controller/SysColumnController.java | 36 +++++++++++++------ 1 file changed, 25 insertions(+), 11 deletions(-) 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);