当前位置:网站首页>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】);
});
}
边栏推荐
- 泰山OFFICE技术讲座:英寸,厘米,磅,派卡,提,行,字行,像素的换算关系
- 活动回顾|7月6日安远AI x 机器之心系列讲座第2期|麻省理工教授Max Tegmark分享「人类与AI的共生演化 」
- Pytoch learning notes -- seresnet50 construction
- 兆骑科创海内外高层次创新创业人才服务平台,双创成果转化平台
- Experimental reproduction of image classification (reasoning only) based on caffe resnet-50 network
- MySQL tutorial 66 data table query statement
- Product upgrade observation station in June
- 哪个led显示屏厂家更好
- Gary marcus: learning a language is more difficult than you think
- 产品动态丨Android 13 高效适配全新升级
猜你喜欢

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

Product dynamics - Android 13 high-efficiency adaptation new upgrade

推荐收藏,这或许是最全的类别型特征的编码方法总结

JWT diagram

Circulaindicator component, which makes the indicator style more diversified

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

Gary marcus: learning a language is more difficult than you think

基于Caffe ResNet-50网络实现图片分类(仅推理)的实验复现

Matlab -- CVX optimization kit installation

Pytoch learning notes advanced_ CNN (using perception_module) implements MNIST dataset classification - (comments and results)
随机推荐
MySQL tutorial 71-where conditional query data
【服务器数据恢复】HP EVA服务器存储意外断电导致RAID信息丢失的数据恢复案例
Release of v6.5.1/2/3 series of versions of Xingyun housekeeper: the ability of database OpenAPI continues to be strengthened
leetcode:154. 寻找旋转排序数组中的最小值 II【关于旋转排序数组的中后定位二分法】
Ml image depth learning and convolution neural network
30行自己写并发工具类(Semaphore, CyclicBarrier, CountDownLatch)
Leetcode - 303 area and retrieval - array immutable (design prefix and array)
ML - Speech - Introduction to speech processing
How Google cloud disk is associated with Google colab
没错,请求DNS服务器还可以使用UDP协议
阿唐的小帮手
pymongo保存dataframe格式的数据(insert_one, insert_many, 多线程保存)
Endnote cannot edit range resolution
Data system partition design - partition and secondary index
Why is preparestatement better and safer?
Introduction to redis
MySQL 悲观锁
[wechat applet] detailed explanation of applet host environment
MySQL tutorial 66 data table query statement
ML - Speech - traditional speech model