完善删除栏目的对子级栏目以及栏目下的文章处理

master
rong.liu 2 years ago
parent 202b9d7846
commit d6b620f945
  1. 36
      src/main/java/com/huoran/iasf/controller/SysColumnController.java

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

Loading…
Cancel
Save