Search in sources :

Example 6 with SysMenu

use of com.ruoyi.common.core.domain.entity.SysMenu in project RuoYi-Vue by yangzongzhuan.

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 7 with SysMenu

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

the class SysLoginController method getRouters.

/**
 * 获取路由信息
 *
 * @return 路由信息
 */
@GetMapping("getRouters")
public AjaxResult getRouters() {
    LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
    // 用户信息
    SysUser user = loginUser.getUser();
    List<SysMenu> menus = menuService.selectMenuTreeByUserId(user.getUserId());
    return AjaxResult.success(menuService.buildMenus(menus));
}
Also used : SysUser(com.ruoyi.common.core.domain.entity.SysUser) SysMenu(com.ruoyi.common.core.domain.entity.SysMenu) LoginUser(com.ruoyi.common.core.domain.model.LoginUser) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 8 with SysMenu

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

the class SysMenuController method roleMenuTreeselect.

/**
 * 加载对应角色菜单列表树
 */
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId) {
    LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
    List<SysMenu> menus = menuService.selectMenuList(loginUser.getUser().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) LoginUser(com.ruoyi.common.core.domain.model.LoginUser) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 9 with SysMenu

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

the class SysMenuController method treeselect.

/**
 * 获取菜单下拉树列表
 */
@GetMapping("/treeselect")
public AjaxResult treeselect(SysMenu menu) {
    LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
    Long userId = loginUser.getUser().getUserId();
    List<SysMenu> menus = menuService.selectMenuList(menu, userId);
    return AjaxResult.success(menuService.buildMenuTreeSelect(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)

Example 10 with SysMenu

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

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