Search in sources :

Example 26 with SysMenu

use of com.ruoyi.common.core.domain.entity.SysMenu in project RuoYi-Vue 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.common.core.domain.entity.SysMenu) ArrayList(java.util.ArrayList)

Example 27 with SysMenu

use of com.ruoyi.common.core.domain.entity.SysMenu in project hocassian-media-matrix by hokaso.

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.common.core.domain.entity.SysMenu)

Example 28 with SysMenu

use of com.ruoyi.common.core.domain.entity.SysMenu in project hocassian-media-matrix by hokaso.

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.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache())));
        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())));
            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) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) LinkedList(java.util.LinkedList) RouterVo(com.ruoyi.system.domain.vo.RouterVo)

Example 29 with SysMenu

use of com.ruoyi.common.core.domain.entity.SysMenu in project hocassian-media-matrix by hokaso.

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.common.core.domain.entity.SysMenu)

Example 30 with SysMenu

use of com.ruoyi.common.core.domain.entity.SysMenu in project hocassian-media-matrix by hokaso.

the class SysMenuController method list.

/**
 * 获取菜单列表
 */
@PreAuthorize("@ss.hasPermi('system:menu:list')")
@GetMapping("/list")
public AjaxResult list(SysMenu menu) {
    LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
    Long userId = loginUser.getUser().getUserId();
    List<SysMenu> menus = menuService.selectMenuList(menu, userId);
    return AjaxResult.success(menus);
}
Also used : SysMenu(com.ruoyi.common.core.domain.entity.SysMenu) LoginUser(com.ruoyi.common.core.domain.model.LoginUser) GetMapping(org.springframework.web.bind.annotation.GetMapping) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

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