Search in sources :

Example 11 with SysMenu

use of com.ruoyi.system.domain.SysMenu in project RuoYi-Cloud by yangzongzhuan.

the class SysMenuServiceImpl method getChildPerms.

/**
 * 根据父节点的ID获取所有子节点
 *
 * @param list 分类表
 * @param parentId 传入的父节点ID
 * @return String
 */
public List<SysMenu> getChildPerms(List<SysMenu> list, int parentId) {
    List<SysMenu> returnList = new ArrayList<SysMenu>();
    for (Iterator<SysMenu> iterator = list.iterator(); iterator.hasNext(); ) {
        SysMenu t = (SysMenu) iterator.next();
        // 一、根据传入的某个父节点ID,遍历该父节点的所有子节点
        if (t.getParentId() == parentId) {
            recursionFn(list, t);
            returnList.add(t);
        }
    }
    return returnList;
}
Also used : SysMenu(com.ruoyi.system.domain.SysMenu) ArrayList(java.util.ArrayList)

Example 12 with SysMenu

use of com.ruoyi.system.domain.SysMenu in project RuoYi-Cloud by yangzongzhuan.

the class SysMenuServiceImpl method buildMenuTree.

/**
 * 构建前端所需要树结构
 *
 * @param menus 菜单列表
 * @return 树结构列表
 */
@Override
public List<SysMenu> buildMenuTree(List<SysMenu> menus) {
    List<SysMenu> returnList = new ArrayList<SysMenu>();
    List<Long> tempList = new ArrayList<Long>();
    for (SysMenu dept : menus) {
        tempList.add(dept.getMenuId());
    }
    for (Iterator<SysMenu> iterator = menus.iterator(); iterator.hasNext(); ) {
        SysMenu menu = (SysMenu) iterator.next();
        // 如果是顶级节点, 遍历该父节点的所有子节点
        if (!tempList.contains(menu.getParentId())) {
            recursionFn(menus, menu);
            returnList.add(menu);
        }
    }
    if (returnList.isEmpty()) {
        returnList = menus;
    }
    return returnList;
}
Also used : SysMenu(com.ruoyi.system.domain.SysMenu) ArrayList(java.util.ArrayList)

Example 13 with SysMenu

use of com.ruoyi.system.domain.SysMenu in project RuoYi-Cloud-Oracle by yangzongzhuan.

the class SysMenuServiceImpl method getChildPerms.

/**
 * 根据父节点的ID获取所有子节点
 *
 * @param list 分类表
 * @param parentId 传入的父节点ID
 * @return String
 */
public List<SysMenu> getChildPerms(List<SysMenu> list, int parentId) {
    List<SysMenu> returnList = new ArrayList<SysMenu>();
    for (Iterator<SysMenu> iterator = list.iterator(); iterator.hasNext(); ) {
        SysMenu t = (SysMenu) iterator.next();
        // 一、根据传入的某个父节点ID,遍历该父节点的所有子节点
        if (t.getParentId() == parentId) {
            recursionFn(list, t);
            returnList.add(t);
        }
    }
    return returnList;
}
Also used : SysMenu(com.ruoyi.system.domain.SysMenu) ArrayList(java.util.ArrayList)

Example 14 with SysMenu

use of com.ruoyi.system.domain.SysMenu in project RuoYi-Cloud-Oracle by yangzongzhuan.

the class SysMenuServiceImpl method recursionFn.

/**
 * 递归列表
 *
 * @param list
 * @param t
 */
private void recursionFn(List<SysMenu> list, SysMenu t) {
    // 得到子节点列表
    List<SysMenu> childList = getChildList(list, t);
    t.setChildren(childList);
    for (SysMenu tChild : childList) {
        if (hasChild(list, tChild)) {
            recursionFn(list, tChild);
        }
    }
}
Also used : SysMenu(com.ruoyi.system.domain.SysMenu)

Example 15 with SysMenu

use of com.ruoyi.system.domain.SysMenu in project RuoYi-Cloud-Oracle by yangzongzhuan.

the class SysMenuServiceImpl method getChildList.

/**
 * 得到子节点列表
 */
private List<SysMenu> getChildList(List<SysMenu> list, SysMenu t) {
    List<SysMenu> tlist = new ArrayList<SysMenu>();
    Iterator<SysMenu> it = list.iterator();
    while (it.hasNext()) {
        SysMenu n = (SysMenu) it.next();
        if (n.getParentId().longValue() == t.getMenuId().longValue()) {
            tlist.add(n);
        }
    }
    return tlist;
}
Also used : SysMenu(com.ruoyi.system.domain.SysMenu) ArrayList(java.util.ArrayList)

Aggregations

SysMenu (com.ruoyi.system.domain.SysMenu)17 ArrayList (java.util.ArrayList)8 MetaVo (com.ruoyi.system.domain.vo.MetaVo)3 RouterVo (com.ruoyi.system.domain.vo.RouterVo)3 AjaxResult (com.ruoyi.common.core.web.domain.AjaxResult)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 GetMapping (org.springframework.web.bind.annotation.GetMapping)2