| | |
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.framework.web.domain.TreeSelect;
|
| | | import com.ruoyi.project.system.domain.SysMenu;
|
| | | import com.ruoyi.project.system.domain.SysRole;
|
| | | import com.ruoyi.project.system.domain.SysUser;
|
| | | import com.ruoyi.project.system.domain.vo.MetaVo;
|
| | | import com.ruoyi.project.system.domain.vo.RouterVo;
|
| | | import com.ruoyi.project.system.mapper.SysMenuMapper;
|
| | | import com.ruoyi.project.system.mapper.SysRoleMapper;
|
| | | import com.ruoyi.project.system.mapper.SysRoleMenuMapper;
|
| | | import com.ruoyi.project.system.service.ISysMenuService;
|
| | |
|
| | |
| | |
|
| | | @Autowired
|
| | | private SysMenuMapper menuMapper;
|
| | | |
| | | @Autowired
|
| | | private SysRoleMapper roleMapper;
|
| | |
|
| | | @Autowired
|
| | | private SysRoleMenuMapper roleMenuMapper;
|
| | |
| | | @Override
|
| | | public List<Integer> selectMenuListByRoleId(Long roleId)
|
| | | {
|
| | | return menuMapper.selectMenuListByRoleId(roleId);
|
| | | SysRole role = roleMapper.selectRoleById(roleId);
|
| | | return menuMapper.selectMenuListByRoleId(roleId, role.isMenuCheckStrictly());
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | router.setName(getRouteName(menu));
|
| | | router.setPath(getRouterPath(menu));
|
| | | router.setComponent(getComponent(menu));
|
| | | router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon()));
|
| | | 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()))
|
| | | {
|
| | |
| | | children.setPath(menu.getPath());
|
| | | children.setComponent(menu.getComponent());
|
| | | children.setName(StringUtils.capitalize(menu.getPath()));
|
| | | children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon()));
|
| | | children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache())));
|
| | | childrenList.add(children);
|
| | | router.setChildren(childrenList);
|
| | | }
|
| | |
| | | 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 t = (SysMenu) iterator.next();
|
| | | // 根据传入的某个父节点ID,遍历该父节点的所有子节点
|
| | | if (t.getParentId() == 0)
|
| | | SysMenu menu = (SysMenu) iterator.next();
|
| | | // 如果是顶级节点, 遍历该父节点的所有子节点
|
| | | if (!tempList.contains(menu.getParentId()))
|
| | | {
|
| | | recursionFn(menus, t);
|
| | | returnList.add(t);
|
| | | recursionFn(menus, menu);
|
| | | returnList.add(menu);
|
| | | }
|
| | | }
|
| | | if (returnList.isEmpty())
|
| | |
| | | {
|
| | | if (hasChild(list, tChild))
|
| | | {
|
| | | // 判断是否有子节点
|
| | | Iterator<SysMenu> it = childList.iterator();
|
| | | while (it.hasNext())
|
| | | {
|
| | | SysMenu n = (SysMenu) it.next();
|
| | | recursionFn(list, n);
|
| | | }
|
| | | recursionFn(list, tChild);
|
| | | }
|
| | | }
|
| | | }
|