1,
Set<AuthResourcePO> authResourcePOSet = Sets.newHashSet();
Long dialogInitAuthResourceId = 387L;
//根据父权限id获取该权限以及该权限下所有权限的集合
authResourcePOSet = findChildAuthResource(authResourcePOSet, dialogInitAuthResourceId);
//根权限的id得到该权限ID以及该权限下所有子权限ID的集合
List<Long> authResourceIdList = authResourcePOSet.stream().map(AuthResourcePO::getAuthResourceId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
2,
private Set<AuthResourcePO> findChildAuthResource(Set<AuthResourcePO> authResourcePOSet, Long dialogInitAuthResourceId) {
AuthResourcePO authResourcePO = authResourceService.selectByKey(dialogInitAuthResourceId);
if (authResourcePO != null) {
authResourcePOSet.add(authResourcePO);
}
//查找子节点,递归算法一定要有一个退出条件
List<AuthResourcePO> authResourcePOS = authResourceService.selectByAuthResourceId(dialogInitAuthResourceId);
for (AuthResourcePO authResourceItem : authResourcePOS) {
findChildAuthResource(authResourcePOSet, authResourceItem.getAuthResourceId());
}
return authResourcePOSet;
}
点击查看更多内容
为 TA 点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦