当前位置:网站首页>权限管理-删除菜单(递归)
权限管理-删除菜单(递归)
2022-07-25 15:43:00 【Leon_Jinhai_Sun】
//============递归删除菜单==================================
@Override
public void removeChildByIdGuli(String id) {
//1 创建list集合,用于封装所有删除菜单id值
List<String> idList = new ArrayList<>();
//2 向idList集合设置删除菜单id,(根据Id删除菜单)
this.selectPermissionChildById(id,idList);
//把当前id封装到list里面
idList.add(id);
baseMapper.deleteBatchIds(idList);//以终为始,我最后是要上去删除一个集合,所以在上面新建了一个集合
}
//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());//通过Id批量查询,因为上面是deleteBatchIds(idList)
//递归查询
this.selectPermissionChildById(item.getId(),idList);
});
} //============递归删除菜单==================================
@Override
public void removeChildByIdGuli(String id) {
//1 创建list集合,用于封装所有删除菜单id值
List<String> idList【封装要删除的Id】 = new ArrayList<>();
//2 向idList集合设置删除菜单id,(根据Id删除菜单)
this.selectPermissionChildById(id,idList);
//把当前id封装到list里面
idList【封装要删除的Id】 .add(id);
baseMapper.deleteBatchIds(idList【封装要删除的Id】 );//以终为始,我最后是要上去删除一个集合,所以在上面新建了一个集合
}
//2 根据当前菜单id,查询菜单里面子菜单id,封装到list集合
private void selectPermissionChildById(String id, List<String> idList【封装要删除的Id】) {
//查询菜单里面子菜单id
QueryWrapper<Permission> wrapper = new QueryWrapper<>();
wrapper.eq("pid【1级Id】 ",id【2级Id】);
wrapper.select("id");//把所有2级id里是1级id的id都筛选出来
List<Permission> childIdList = baseMapper.selectList(wrapper);//【符合上述条件的2级Id】
//把childIdList里面菜单id值获取出来,封装idList里面,做递归查询
childIdList.stream().forEach(item -> {
//封装idList里面
idList【封装要删除的Id】.add(item.getId());//通过Id批量查询,因为上面是deleteBatchIds(idList)
//递归查询
this.selectPermissionChildById(item.getId()【符合上述条件的2级Id】,idList【封装要删除的Id】);
});
}
边栏推荐
- Copy a word style template to another document
- MySQL乐观锁
- 共2600页!又一份神级的面试手册面世~
- MySQL教程65-MySQL操作表中数据
- 兆骑科创海内外高层次创新创业人才服务平台,双创成果转化平台
- MySQL教程71-WHERE 条件查询数据
- Data system partition design - Request Routing
- Geogle colab notes 1-- run the.Py file on the cloud hard disk of Geogle
- CVPR 2022 | in depth study of batch normalized estimation offset in network
- Beyond compare 4 realizes class file comparison [latest]
猜你喜欢

活动回顾|7月6日安远AI x 机器之心系列讲座第2期|麻省理工教授Max Tegmark分享「人类与AI的共生演化 」

Pytoch learning notes -- seresnet50 construction

【莎士比亚:保持做人的乐趣】

HDD杭州站·HarmonyOS技术专家分享HUAWEI DevEco Studio特色功能

Pytoch learning notes -- Summary of common functions 3

Reasons for data format conversion when matlab reads the displayed image

MySQL—常用SQL语句整理总结

TypeError: Unrecognized value type: <class ‘str‘> ParserError: Unknown string format

The second revolution of reporting tools

开发者如何为React Native选择合适的数据库
随机推荐
Gary marcus: learning a language is more difficult than you think
I interviewed 8 companies and got 5 offers in a week. Share my experience
Leetcode - 359 log rate limiter (Design)
The difference between VaR, let and Const
Beyond Compare 4 实现class文件对比【最新】
Cf365-e - Mishka and divisors, number theory +dp
BSC smart chain contract mode system development details
CVPR 2022 | 网络中批处理归一化估计偏移的深入研究
Baseband simulation system experiment of 4pam in Gaussian channel and Rayleigh channel
Zhaoqi Kechuang high-quality overseas returnee talent entrepreneurship and innovation service platform, online live broadcast Roadshow
Use cpolar to build a business website (how to buy a domain name)
LeetCode - 359 日志速率限制器 (设计)
Redis distributed lock, it's really impossible without it
Solve the vender-base.66c6fc1c0b393478adf7.js:6 typeerror: cannot read property 'validate' of undefined problem
Leetcode - 677 key value mapping (Design)*
MySQL tutorial 66 data table query statement
Reasons for data format conversion when matlab reads the displayed image
推荐收藏,这或许是最全的类别型特征的编码方法总结
电阻电路的等效变化(Ⅱ)
基于Caffe ResNet-50网络实现图片分类(仅推理)的实验复现