当前位置:网站首页>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】);
});
}
边栏推荐
- Implementation of recommendation system collaborative filtering in spark
- Alibaba's internal "100 billion level concurrent system architecture design notes" are all inclusive, too comprehensive
- 「数字安全」警惕 NFT的七大骗局
- 权限管理-角色分配菜单
- TypeError: Unrecognized value type: <class ‘str‘> ParserError: Unknown string format
- 哪个led显示屏厂家更好
- How Google cloud disk is associated with Google colab
- Zhaoqi Kechuang high-quality overseas returnee talent entrepreneurship and innovation service platform, online live broadcast Roadshow
- MySQL乐观锁
- Pytoch learning notes -- Summary of common functions of pytoch 1
猜你喜欢

Leetcode - 379 telephone directory management system (Design)

tkinter模块高级操作(一)—— 透明按钮、透明文本框、自定义按钮及自定义文本框

Leetcode - 232 realize queue with stack (design double stack to realize queue)

Circulaindicator component, which makes the indicator style more diversified

Huawei 2023 starts to warm up in advance! Zuo Shen's program code interview guide comes in handy

Pytoch learning notes -- Summary of common functions of pytoch 1

leetcode:528. 按权重随机选择【普通随机失效 + 要用前缀和二分】

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

用GaussDB(for Redis)存画像,推荐业务轻松降本60%

「数字安全」警惕 NFT的七大骗局
随机推荐
Leetcode - 677 key value mapping (Design)*
十字链表的存储结构
Baseband simulation system experiment of 4pam in Gaussian channel and Rayleigh channel
ServletConfig 类和ServletContext 类
MySQL-自增锁
2022-07-25日报:微软提出CodeT:代码生成新SOTA,20个点的性能提升
R语言ggplot2可视化线图(line)、自定义配置标题文本相关内容颜色和图例(legend)颜色相匹配(和分组线图的颜色相匹配、match colors of groups)
Visual studio 2022 view class diagram
ML - Speech - Introduction to speech processing
Dpdk packet receiving and sending problem case: non packet receiving problem location triggered by mismatched packet sending and receiving function
tkinter模块高级操作(一)—— 透明按钮、透明文本框、自定义按钮及自定义文本框
Matlab -- CVX optimization kit installation
阿唐的小帮手
leetcode:528. 按权重随机选择【普通随机失效 + 要用前缀和二分】
mysql 隔离级别事务
权限管理-角色分配菜单
Golang review summary
Waterfall flow layout
「数字安全」警惕 NFT的七大骗局
Release of v6.5.1/2/3 series of versions of Xingyun housekeeper: the ability of database OpenAPI continues to be strengthened