当前位置:网站首页>Permission management - delete menu (recursive)
Permission management - delete menu (recursive)
2022-07-25 16:04:00 【Leon_ Jinhai_ Sun】
//============ Recursively delete menu ==================================
@Override
public void removeChildByIdGuli(String id) {
//1 establish list aggregate , Used to encapsulate all delete menus id value
List<String> idList = new ArrayList<>();
//2 towards idList Set settings delete menu id,( according to Id Delete menu )
this.selectPermissionChildById(id,idList);
// Put the present id Package to list Inside
idList.add(id);
baseMapper.deleteBatchIds(idList);// Start with the end , Finally, I want to delete a collection , So a new set is created on it
}
//2 According to the current menu id, Sub menu in the query menu id, Package to list aggregate
private void selectPermissionChildById(String id, List<String> idList) {
// Sub menu in the query menu id
QueryWrapper<Permission> wrapper = new QueryWrapper<>();
wrapper.eq("pid",id);
wrapper.select("id");
List<Permission> childIdList = baseMapper.selectList(wrapper);
// hold childIdList Inside the menu id It's worth getting , encapsulation idList Inside , Do recursive queries
childIdList.stream().forEach(item -> {
// encapsulation idList Inside
idList.add(item.getId());// adopt Id Batch query , Because it's deleteBatchIds(idList)
// recursive query
this.selectPermissionChildById(item.getId(),idList);
});
} //============ Recursively delete menu ==================================
@Override
public void removeChildByIdGuli(String id) {
//1 establish list aggregate , Used to encapsulate all delete menus id value
List<String> idList【 Encapsulate the to be deleted Id】 = new ArrayList<>();
//2 towards idList Set settings delete menu id,( according to Id Delete menu )
this.selectPermissionChildById(id,idList);
// Put the present id Package to list Inside
idList【 Encapsulate the to be deleted Id】 .add(id);
baseMapper.deleteBatchIds(idList【 Encapsulate the to be deleted Id】 );// Start with the end , Finally, I want to delete a collection , So a new set is created on it
}
//2 According to the current menu id, Sub menu in the query menu id, Package to list aggregate
private void selectPermissionChildById(String id, List<String> idList【 Encapsulate the to be deleted Id】) {
// Sub menu in the query menu id
QueryWrapper<Permission> wrapper = new QueryWrapper<>();
wrapper.eq("pid【1 level Id】 ",id【2 level Id】);
wrapper.select("id");// Put all the 2 level id Is in the 1 level id Of id They're all screened out
List<Permission> childIdList = baseMapper.selectList(wrapper);//【 Meet the above conditions 2 level Id】
// hold childIdList Inside the menu id It's worth getting , encapsulation idList Inside , Do recursive queries
childIdList.stream().forEach(item -> {
// encapsulation idList Inside
idList【 Encapsulate the to be deleted Id】.add(item.getId());// adopt Id Batch query , Because it's deleteBatchIds(idList)
// recursive query
this.selectPermissionChildById(item.getId()【 Meet the above conditions 2 level Id】,idList【 Encapsulate the to be deleted Id】);
});
}
边栏推荐
- MySQL 元数据锁(MDL)
- PageHelper.startPage没有生效问题
- Sword finger offer | number of 1 in binary
- 狂神redis笔记12
- 兆骑科创高质量海归人才双创服务平台,线上直播路演
- Ml image depth learning and convolution neural network
- The difference between VaR, let and Const
- [wechat applet] detailed explanation of applet host environment
- Geogle colab notes 1-- run the.Py file on the cloud hard disk of Geogle
- R语言ggplot2可视化线图(line)、自定义配置标题文本相关内容颜色和图例(legend)颜色相匹配(和分组线图的颜色相匹配、match colors of groups)
猜你喜欢

Introduction to redis

Boomi荣获“多元化最佳首席执行官奖”和“职业成长最佳公司奖”,在大型公司类别中跻身50强

不愧是阿里内部“千亿级并发系统架构设计笔记”面面俱到,太全了

leetcode:6127. 优质数对的数目【位运算找规律 + 两数之和大于等于k + 二分】

Visual studio 2022 view class diagram

十字链表的存储结构

Analysis and solution of data and clock mismatch delay in SPI transmission

面试8家公司,1周拿了5个offer,分享一下自己的心得

Product upgrade observation station in June

Leetcode - 677 key value mapping (Design)*
随机推荐
MySQL 悲观锁
Gary marcus: learning a language is more difficult than you think
Leetcode - 379 telephone directory management system (Design)
Endnote add Chinese gbt7714 style how to quote documents in word
Distributed | practice: smoothly migrate business from MYCAT to dble
Understand "average load"
活动回顾|7月6日安远AI x 机器之心系列讲座第2期|麻省理工教授Max Tegmark分享「人类与AI的共生演化 」
Data system partition design - Request Routing
Leetcode - 380 o (1) time to insert, delete and get random elements (design hash table + array)
权限管理-删除菜单(递归)
权限管理-角色分配菜单
CircleIndicator组件,使指示器风格更加多样化
如何构建面向海量数据、高实时要求的企业级OLAP数据引擎?
【服务器数据恢复】HP EVA服务器存储意外断电导致RAID信息丢失的数据恢复案例
兆骑科创高质量海归人才双创服务平台,线上直播路演
PageHelper.startPage没有生效问题
华为2023届提前批预热开始!左 神的程序代码面试指南终派上用场
递归菜单查询(递归:自己查自己)
[IJCAI 2022] parameter efficient large model sparse training method, which greatly reduces the resources required for sparse training
Record Locks(记录锁)