| | |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.domain.TreeSelect; |
| | | import com.ruoyi.common.core.domain.entity.SysMenu; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.domain.vo.MetaVo; |
| | | import com.ruoyi.system.domain.vo.RouterVo; |
| | | import com.ruoyi.system.mapper.SysMenuMapper; |
| | | import com.ruoyi.system.mapper.SysRoleMapper; |
| | | import com.ruoyi.system.mapper.SysRoleMenuMapper; |
| | | import com.ruoyi.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()) |
| | |
| | | { |
| | | component = menu.getComponent(); |
| | | } |
| | | else if (StringUtils.isEmpty(menu.getComponent()) && isParentView(menu)) |
| | | { |
| | | component = UserConstants.PARENT_VIEW; |
| | | } |
| | | return component; |
| | | } |
| | | |
| | |
| | | { |
| | | return menu.getParentId().intValue() == 0 && UserConstants.TYPE_MENU.equals(menu.getMenuType()) |
| | | && menu.getIsFrame().equals(UserConstants.NO_FRAME); |
| | | } |
| | | |
| | | /** |
| | | * 是否为parent_view组件 |
| | | * |
| | | * @param menu 菜单信息 |
| | | * @return 结果 |
| | | */ |
| | | public boolean isParentView(SysMenu menu) |
| | | { |
| | | return menu.getParentId().intValue() != 0 && UserConstants.TYPE_DIR.equals(menu.getMenuType()); |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | if (hasChild(list, tChild)) |
| | | { |
| | | // 判断是否有子节点 |
| | | Iterator<SysMenu> it = childList.iterator(); |
| | | while (it.hasNext()) |
| | | { |
| | | SysMenu n = (SysMenu) it.next(); |
| | | recursionFn(list, n); |
| | | } |
| | | recursionFn(list, tChild); |
| | | } |
| | | } |
| | | } |