Search in sources :

Example 1 with SysMenu

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

the class SysMenuServiceImpl method checkMenuNameUnique.

/**
 * 校验菜单名称是否唯一
 *
 * @param menu 菜单信息
 * @return 结果
 */
@Override
public String checkMenuNameUnique(SysMenu menu) {
    Long menuId = StringUtils.isNull(menu.getMenuId()) ? -1L : menu.getMenuId();
    SysMenu info = menuMapper.checkMenuNameUnique(menu.getMenuName(), menu.getParentId());
    if (StringUtils.isNotNull(info) && info.getMenuId().longValue() != menuId.longValue()) {
        return UserConstants.NOT_UNIQUE;
    }
    return UserConstants.UNIQUE;
}
Also used : SysMenu(com.ruoyi.system.domain.SysMenu)

Example 2 with SysMenu

use of com.ruoyi.system.domain.SysMenu in project RuoYi-Cloud 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)

Example 3 with SysMenu

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

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.getQuery());
        router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath()));
        List<SysMenu> cMenus = menu.getChildren();
        if (!cMenus.isEmpty() && cMenus.size() > 0 && 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.getQuery());
            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.system.domain.SysMenu) MetaVo(com.ruoyi.system.domain.vo.MetaVo) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) LinkedList(java.util.LinkedList) RouterVo(com.ruoyi.system.domain.vo.RouterVo)

Example 4 with SysMenu

use of com.ruoyi.system.domain.SysMenu in project RuoYi-Cloud-Oracle 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 5 with SysMenu

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

the class SysMenuServiceImpl method checkMenuNameUnique.

/**
 * 校验菜单名称是否唯一
 *
 * @param menu 菜单信息
 * @return 结果
 */
@Override
public String checkMenuNameUnique(SysMenu menu) {
    Long menuId = StringUtils.isNull(menu.getMenuId()) ? -1L : menu.getMenuId();
    SysMenu info = menuMapper.checkMenuNameUnique(menu.getMenuName(), menu.getParentId());
    if (StringUtils.isNotNull(info) && info.getMenuId().longValue() != menuId.longValue()) {
        return UserConstants.NOT_UNIQUE;
    }
    return UserConstants.UNIQUE;
}
Also used : SysMenu(com.ruoyi.system.domain.SysMenu)

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