Search in sources :

Example 1 with SysMenu

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

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

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

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

Example 3 with SysMenu

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

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

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

Example 5 with SysMenu

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

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