Search in sources :

Example 16 with SysMenu

use of com.ruoyi.common.core.domain.entity.SysMenu in project RuoYi-Flowable-Plus by KonBAI-Q.

the class SysMenuServiceImpl method buildMenus.

/**
 * 构建前端路由所需要的菜单
 *
 * @param menus 菜单列表
 * @return 路由列表
 */
@Override
public List<RouterVo> buildMenus(List<SysMenu> menus) {
    List<RouterVo> routers = new LinkedList<RouterVo>();
    for (SysMenu menu : menus) {
        RouterVo router = new RouterVo();
        router.setHidden("1".equals(menu.getVisible()));
        router.setName(getRouteName(menu));
        router.setPath(getRouterPath(menu));
        router.setComponent(getComponent(menu));
        router.setQuery(menu.getQueryParam());
        router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath()));
        List<SysMenu> cMenus = menu.getChildren();
        if (!cMenus.isEmpty() && UserConstants.TYPE_DIR.equals(menu.getMenuType())) {
            router.setAlwaysShow(true);
            router.setRedirect("noRedirect");
            router.setChildren(buildMenus(cMenus));
        } else if (isMenuFrame(menu)) {
            router.setMeta(null);
            List<RouterVo> childrenList = new ArrayList<RouterVo>();
            RouterVo children = new RouterVo();
            children.setPath(menu.getPath());
            children.setComponent(menu.getComponent());
            children.setName(StringUtils.capitalize(menu.getPath()));
            children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath()));
            children.setQuery(menu.getQueryParam());
            childrenList.add(children);
            router.setChildren(childrenList);
        } else if (menu.getParentId().intValue() == 0 && isInnerLink(menu)) {
            router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon()));
            router.setPath("/");
            List<RouterVo> childrenList = new ArrayList<RouterVo>();
            RouterVo children = new RouterVo();
            String routerPath = innerLinkReplaceEach(menu.getPath());
            children.setPath(routerPath);
            children.setComponent(UserConstants.INNER_LINK);
            children.setName(StringUtils.capitalize(routerPath));
            children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), menu.getPath()));
            childrenList.add(children);
            router.setChildren(childrenList);
        }
        routers.add(router);
    }
    return routers;
}
Also used : SysMenu(com.ruoyi.common.core.domain.entity.SysMenu) MetaVo(com.ruoyi.system.domain.vo.MetaVo) RouterVo(com.ruoyi.system.domain.vo.RouterVo)

Example 17 with SysMenu

use of com.ruoyi.common.core.domain.entity.SysMenu in project RuoYi-Flowable-Plus by KonBAI-Q.

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 (SysMenu t : list) {
        // 一、根据传入的某个父节点ID,遍历该父节点的所有子节点
        if (t.getParentId() == parentId) {
            recursionFn(list, t);
            returnList.add(t);
        }
    }
    return returnList;
}
Also used : SysMenu(com.ruoyi.common.core.domain.entity.SysMenu)

Example 18 with SysMenu

use of com.ruoyi.common.core.domain.entity.SysMenu in project wumei-smart by kerwincui.

the class SysMenuController method roleMenuTreeselect.

/**
 * 加载对应角色菜单列表树
 */
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId) {
    List<SysMenu> menus = menuService.selectMenuList(getUserId());
    AjaxResult ajax = AjaxResult.success();
    ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId));
    ajax.put("menus", menuService.buildMenuTreeSelect(menus));
    return ajax;
}
Also used : AjaxResult(com.ruoyi.common.core.domain.AjaxResult) SysMenu(com.ruoyi.common.core.domain.entity.SysMenu) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 19 with SysMenu

use of com.ruoyi.common.core.domain.entity.SysMenu in project wumei-smart by kerwincui.

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.common.core.domain.entity.SysMenu) ArrayList(java.util.ArrayList)

Example 20 with SysMenu

use of com.ruoyi.common.core.domain.entity.SysMenu in project wumei-smart by kerwincui.

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.common.core.domain.entity.SysMenu) ArrayList(java.util.ArrayList)

Aggregations

SysMenu (com.ruoyi.common.core.domain.entity.SysMenu)30 ArrayList (java.util.ArrayList)12 GetMapping (org.springframework.web.bind.annotation.GetMapping)6 MetaVo (com.ruoyi.system.domain.vo.MetaVo)5 RouterVo (com.ruoyi.system.domain.vo.RouterVo)5 LoginUser (com.ruoyi.common.core.domain.model.LoginUser)4 AjaxResult (com.ruoyi.common.core.domain.AjaxResult)3 LinkedList (java.util.LinkedList)3 List (java.util.List)3 SysUser (com.ruoyi.common.core.domain.entity.SysUser)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1