|
|
|
@ -114,7 +114,7 @@ public class PermissionServiceImpl extends ServiceImpl<SysPermissionMapper, SysP |
|
|
|
|
for (SysPermission sysPermission : result) { |
|
|
|
|
SysPermission parent = sysPermissionMapper.selectById(sysPermission.getPid()); |
|
|
|
|
if (parent != null) { |
|
|
|
|
sysPermission.setPidName(parent.getName()); |
|
|
|
|
// sysPermission.setPidName(parent.getName());
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -216,10 +216,50 @@ public class PermissionServiceImpl extends ServiceImpl<SysPermissionMapper, SysP |
|
|
|
|
* 获取所有菜单权限按钮 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public List<PermissionRespNode> selectAllByTree() { |
|
|
|
|
public List<SysPermission> selectAllByTree() { |
|
|
|
|
|
|
|
|
|
List<SysPermission> list = selectAll(); |
|
|
|
|
return getTree(list, false); |
|
|
|
|
// List<SysPermission> list = selectAll();
|
|
|
|
|
// return getTree(list, false);
|
|
|
|
|
|
|
|
|
|
List<SysPermission> permissionList = baseMapper.selectList(null); |
|
|
|
|
return build(permissionList); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 使用递归方法建菜单 |
|
|
|
|
* @param treeNodes 权限菜单 |
|
|
|
|
* @return 权限菜单 |
|
|
|
|
*/ |
|
|
|
|
private static List<SysPermission> build(List<SysPermission> treeNodes) { |
|
|
|
|
List<SysPermission> trees = new ArrayList<>(); |
|
|
|
|
for (SysPermission treeNode : treeNodes) { |
|
|
|
|
if ("0".equals(treeNode.getPid())) { |
|
|
|
|
treeNode.setLevel(1); |
|
|
|
|
trees.add(findChildren(treeNode,treeNodes)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return trees; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 递归查找子节点 |
|
|
|
|
* @param treeNodes 权限子菜单 |
|
|
|
|
* @return 权限子菜单 |
|
|
|
|
*/ |
|
|
|
|
private static SysPermission findChildren(SysPermission treeNode,List<SysPermission> treeNodes) { |
|
|
|
|
treeNode.setChildren(new ArrayList<SysPermission>()); |
|
|
|
|
|
|
|
|
|
for (SysPermission it : treeNodes) { |
|
|
|
|
if(treeNode.getId().equals(it.getPid())) { |
|
|
|
|
int level = treeNode.getLevel() + 1; |
|
|
|
|
it.setLevel(level); |
|
|
|
|
if (treeNode.getChildren() == null) { |
|
|
|
|
treeNode.setChildren(new ArrayList<>()); |
|
|
|
|
} |
|
|
|
|
treeNode.getChildren().add(findChildren(it,treeNodes)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return treeNode; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -247,7 +287,7 @@ public class PermissionServiceImpl extends ServiceImpl<SysPermissionMapper, SysP |
|
|
|
|
PermissionRespNode respNode = new PermissionRespNode(); |
|
|
|
|
respNode.setId("0"); |
|
|
|
|
respNode.setName("默认顶级菜单"); |
|
|
|
|
respNode.setSpread(true); |
|
|
|
|
// respNode.setSpread(true);
|
|
|
|
|
respNode.setChildren(getTree(list, true)); |
|
|
|
|
result.add(respNode); |
|
|
|
|
return result; |
|
|
|
|