| | |
| | |
|
| | | @Autowired
|
| | | private SysMenuMapper menuMapper;
|
| | | |
| | |
|
| | | @Autowired
|
| | | private SysRoleMapper roleMapper;
|
| | |
|
| | |
| | | router.setQuery(menu.getQuery());
|
| | | router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath()));
|
| | | List<SysMenu> cMenus = menu.getChildren();
|
| | | if (!cMenus.isEmpty() && cMenus.size() > 0 && UserConstants.TYPE_DIR.equals(menu.getMenuType()))
|
| | | if (StringUtils.isNotEmpty(cMenus) && UserConstants.TYPE_DIR.equals(menu.getMenuType()))
|
| | | {
|
| | | router.setAlwaysShow(true);
|
| | | router.setRedirect("noRedirect");
|
| | |
| | | RouterVo children = new RouterVo();
|
| | | children.setPath(menu.getPath());
|
| | | children.setComponent(menu.getComponent());
|
| | | children.setName(StringUtils.capitalize(menu.getPath()));
|
| | | children.setName(getRouteName(menu.getRouteName(), menu.getPath()));
|
| | | children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath()));
|
| | | children.setQuery(menu.getQuery());
|
| | | childrenList.add(children);
|
| | |
| | | String routerPath = innerLinkReplaceEach(menu.getPath());
|
| | | children.setPath(routerPath);
|
| | | children.setComponent(UserConstants.INNER_LINK);
|
| | | children.setName(StringUtils.capitalize(routerPath));
|
| | | children.setName(getRouteName(menu.getRouteName(), routerPath));
|
| | | children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), menu.getPath()));
|
| | | 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());
|
| | | }
|
| | | List<Long> tempList = menus.stream().map(SysMenu::getMenuId).collect(Collectors.toList());
|
| | | for (Iterator<SysMenu> iterator = menus.iterator(); iterator.hasNext();)
|
| | | {
|
| | | SysMenu menu = (SysMenu) iterator.next();
|
| | |
| | | * @return 结果
|
| | | */
|
| | | @Override
|
| | | public String checkMenuNameUnique(SysMenu menu)
|
| | | public boolean checkMenuNameUnique(SysMenu menu)
|
| | | {
|
| | | Long menuId = StringUtils.isNull(menu.getMenuId()) ? -1L : menu.getMenuId();
|
| | | SysMenu info = menuMapper.checkMenuNameUnique(menu.getMenuName(), menu.getParentId());
|
| | |
| | | */
|
| | | public String getRouteName(SysMenu menu)
|
| | | {
|
| | | String routerName = StringUtils.capitalize(menu.getPath());
|
| | | // 非外链并且是一级目录(类型为目录)
|
| | | if (isMenuFrame(menu))
|
| | | {
|
| | | routerName = StringUtils.EMPTY;
|
| | | return StringUtils.EMPTY;
|
| | | }
|
| | | return routerName;
|
| | | return getRouteName(menu.getRouteName(), menu.getPath());
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取路由名称,如没有配置路由名称则取路由地址
|
| | | * |
| | | * @param routerName 路由名称
|
| | | * @param path 路由地址
|
| | | * @return 路由名称(驼峰格式)
|
| | | */
|
| | | public String getRouteName(String name, String path)
|
| | | {
|
| | | String routerName = StringUtils.isNotEmpty(name) ? name : path;
|
| | | return StringUtils.capitalize(routerName);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | /**
|
| | | * 递归列表
|
| | | *
|
| | | * @param list
|
| | | * @param t
|
| | | * @param list 分类表
|
| | | * @param t 子节点
|
| | | */
|
| | | private void recursionFn(List<SysMenu> list, SysMenu t)
|
| | | {
|
| | |
| | | /**
|
| | | * 内链域名特殊字符替换
|
| | | *
|
| | | * @return
|
| | | * @return 替换后的内链域名
|
| | | */
|
| | | public String innerLinkReplaceEach(String path)
|
| | | {
|
| | | return StringUtils.replaceEach(path, new String[] { Constants.HTTP, Constants.HTTPS, Constants.WWW, "." },
|
| | | new String[] { "", "", "", "/" });
|
| | | return StringUtils.replaceEach(path, new String[] { Constants.HTTP, Constants.HTTPS, Constants.WWW, ".", ":" },
|
| | | new String[] { "", "", "", "/", "/" });
|
| | | }
|
| | | }
|