递归删除菜单
作者:互联网
============递归删除菜单==================================
@Override public void removeChildByIdGuli(String id) { //1 创建list集合,用于封装所有删除菜单id值 List<String> idList = new ArrayList<>(); //2 向idList集合设置删除菜单id this.selectPermissionChildById(id,idList); //把当前id封装到list里面 idList.add(id); baseMapper.deleteBatchIds(idList); }
//2 根据当前菜单id,查询菜单里面子菜单id,封装到list集合
//2 根据当前菜单id,查询菜单里面子菜单id,封装到list集合 private void selectPermissionChildById(String id, List<String> idList) { //查询菜单里面子菜单id QueryWrapper<Permission> wrapper = new QueryWrapper<>(); wrapper.eq("pid",id); wrapper.select("id"); List<Permission> childIdList = baseMapper.selectList(wrapper); //把childIdList里面菜单id值获取出来,封装idList里面,做递归查询 childIdList.stream().forEach(item -> { //封装idList里面 idList.add(item.getId()); //递归查询 this.selectPermissionChildById(item.getId(),idList); }); }
标签:菜单,封装,idList,删除,list,wrapper,递归,id 来源: https://www.cnblogs.com/upupup-999/p/14971039.html