当前位置:网站首页>权限管理-删除菜单(递归)
权限管理-删除菜单(递归)
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】);
});
}
边栏推荐
- Leetcode - 380 o (1) time to insert, delete and get random elements (design hash table + array)
- JVM - classloader and parental delegation model
- Leetcode - 677 key value mapping (Design)*
- MySQL tutorial 66 data table query statement
- 共2600页!又一份神级的面试手册面世~
- LeetCode - 359 日志速率限制器 (设计)
- Where is there a demo to set up the flex CDC to draw the number of MySQL?
- MySQL—用户和权限管控
- Ml image depth learning and convolution neural network
- Boomi荣获“多元化最佳首席执行官奖”和“职业成长最佳公司奖”,在大型公司类别中跻身50强
猜你喜欢

LeetCode - 225 用队列实现栈

Experimental reproduction of image classification (reasoning only) based on caffe resnet-50 network

Pytoch learning notes advanced_ CNN (using perception_module) implements MNIST dataset classification - (comments and results)

JWT diagram

Alibaba's internal "100 billion level concurrent system architecture design notes" are all inclusive, too comprehensive

Leetcode - 359 log rate limiter (Design)
![[IJCAI 2022] parameter efficient large model sparse training method, which greatly reduces the resources required for sparse training](/img/d4/bcc577f320a893c7006177993b2e7a.png)
[IJCAI 2022] parameter efficient large model sparse training method, which greatly reduces the resources required for sparse training

HDD Hangzhou station · harmonyos technical experts share the features of Huawei deveco studio

Understand "average load"

Leetcode - 380 o (1) time to insert, delete and get random elements (design hash table + array)
随机推荐
Distributed | practice: smoothly migrate business from MYCAT to dble
P4552 differential
Copy a word style template to another document
Gary Marcus: 学习语言比你想象的更难
Leetcode - 359 log rate limiter (Design)
JVM—类加载器和双亲委派模型
Cf365-e - Mishka and divisors, number theory +dp
Leetcode - 379 telephone directory management system (Design)
Record Locks(记录锁)
共2600页!又一份神级的面试手册面世~
对this对象的理解
2600 pages in total! Another divine interview manual is available~
Google Blog: training general agents with multi game decision transformer
MySQL教程66-数据表查询语句
CircleIndicator组件,使指示器风格更加多样化
Dpdk packet receiving and sending problem case: non packet receiving problem location triggered by mismatched packet sending and receiving function
推荐系统-协同过滤在Spark中的实现
How matlab produces random complex sequences
一文入门Redis
Qtime definition (manual waste utilization is simple and beautiful)