| | |
| | | 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); |
| | |
| | | * @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); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | 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[] { "", "", "", "/", "/" }); |
| | | } |
| | | } |