delete ruoyi 1.1.6
This commit is contained in:
@ -1,145 +0,0 @@
|
||||
package com.ruoyi.common.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.project.system.menu.domain.Menu;
|
||||
|
||||
/**
|
||||
* 权限数据处理
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class TreeUtils
|
||||
{
|
||||
|
||||
/**
|
||||
* 根据父节点的ID获取所有子节点
|
||||
*
|
||||
* @param list 分类表
|
||||
* @param typeId 传入的父节点ID
|
||||
* @return String
|
||||
*/
|
||||
public static List<Menu> getChildPerms(List<Menu> list, int parentId)
|
||||
{
|
||||
List<Menu> returnList = new ArrayList<Menu>();
|
||||
for (Iterator<Menu> iterator = list.iterator(); iterator.hasNext();)
|
||||
{
|
||||
Menu t = (Menu) iterator.next();
|
||||
// 一、根据传入的某个父节点ID,遍历该父节点的所有子节点
|
||||
if (t.getParentId() == parentId)
|
||||
{
|
||||
recursionFn(list, t);
|
||||
returnList.add(t);
|
||||
}
|
||||
}
|
||||
return returnList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归列表
|
||||
*
|
||||
* @param list
|
||||
* @param Menu
|
||||
*/
|
||||
private static void recursionFn(List<Menu> list, Menu t)
|
||||
{
|
||||
// 得到子节点列表
|
||||
List<Menu> childList = getChildList(list, t);
|
||||
t.setChildren(childList);
|
||||
for (Menu tChild : childList)
|
||||
{
|
||||
if (hasChild(list, tChild))
|
||||
{
|
||||
// 判断是否有子节点
|
||||
Iterator<Menu> it = childList.iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
Menu n = (Menu) it.next();
|
||||
recursionFn(list, n);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到子节点列表
|
||||
*/
|
||||
private static List<Menu> getChildList(List<Menu> list, Menu t)
|
||||
{
|
||||
|
||||
List<Menu> tlist = new ArrayList<Menu>();
|
||||
Iterator<Menu> it = list.iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
Menu n = (Menu) it.next();
|
||||
if (n.getParentId().longValue() == t.getMenuId().longValue())
|
||||
{
|
||||
tlist.add(n);
|
||||
}
|
||||
}
|
||||
return tlist;
|
||||
}
|
||||
|
||||
List<Menu> returnList = new ArrayList<Menu>();
|
||||
|
||||
/**
|
||||
* 根据父节点的ID获取所有子节点
|
||||
*
|
||||
* @param list 分类表
|
||||
* @param typeId 传入的父节点ID
|
||||
* @param prefix 子节点前缀
|
||||
*/
|
||||
public List<Menu> getChildPerms(List<Menu> list, int typeId, String prefix)
|
||||
{
|
||||
if (list == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
for (Iterator<Menu> iterator = list.iterator(); iterator.hasNext();)
|
||||
{
|
||||
Menu node = (Menu) iterator.next();
|
||||
// 一、根据传入的某个父节点ID,遍历该父节点的所有子节点
|
||||
if (node.getParentId() == typeId)
|
||||
{
|
||||
recursionFn(list, node, prefix);
|
||||
}
|
||||
// 二、遍历所有的父节点下的所有子节点
|
||||
/*
|
||||
* if (node.getParentId()==0) { recursionFn(list, node); }
|
||||
*/
|
||||
}
|
||||
return returnList;
|
||||
}
|
||||
|
||||
private void recursionFn(List<Menu> list, Menu node, String p)
|
||||
{
|
||||
// 得到子节点列表
|
||||
List<Menu> childList = getChildList(list, node);
|
||||
if (hasChild(list, node))
|
||||
{
|
||||
// 判断是否有子节点
|
||||
returnList.add(node);
|
||||
Iterator<Menu> it = childList.iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
Menu n = (Menu) it.next();
|
||||
n.setMenuName(p + n.getMenuName());
|
||||
recursionFn(list, n, p + p);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
returnList.add(node);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否有子节点
|
||||
*/
|
||||
private static boolean hasChild(List<Menu> list, Menu t)
|
||||
{
|
||||
return getChildList(list, t).size() > 0 ? true : false;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user