| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | |
| | | @Autowired |
| | | private SysRoleMenuMapper roleMenuMapper; |
| | | |
| | | |
| | | @Value("${isAdmin}") |
| | | private List<Long> isAdmin; |
| | | |
| | | /** |
| | | * 根据用户查询系统菜单列表 |
| | | * |
| | |
| | | if (SysUser.isAdmin(userId)) { |
| | | menuList = menuMapper.selectMenuList(menu); |
| | | } else { |
| | | menu.getParams().put("userId" , userId); |
| | | menu.getParams().put("userId", userId); |
| | | menuList = menuMapper.selectMenuListByUserId(menu); |
| | | } |
| | | return menuList; |
| | |
| | | @Override |
| | | public List<SysMenu> selectMenuTreeByUserId(Long userId) { |
| | | List<SysMenu> menus = null; |
| | | if (SecurityUtils.isAdmin(userId)) { |
| | | // if (SecurityUtils.isAdmin(userId)) { |
| | | if (userId != null && isAdmin.contains(userId)) { |
| | | menus = menuMapper.selectMenuTreeAll(); |
| | | } else { |
| | | menus = menuMapper.selectMenuTreeByUserId(userId); |
| | |
| | | */ |
| | | @Override |
| | | public List<RouterVo> buildMenus(List<SysMenu> menus) { |
| | | log.error("buildMenus的入参为:{}",menus); |
| | | log.error("buildMenus的入参为:{}", menus); |
| | | List<RouterVo> routers = new LinkedList<RouterVo>(); |
| | | for (SysMenu menu : menus) { |
| | | RouterVo router = new RouterVo(); |
| | |
| | | router.setPath(getRouterPath(menu)); |
| | | router.setComponent(getComponent(menu)); |
| | | router.setQuery(menu.getQuery()); |
| | | router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1" , menu.getIsCache()), menu.getPath())); |
| | | 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())) { |
| | | router.setAlwaysShow(true); |
| | |
| | | children.setPath(menu.getPath()); |
| | | children.setComponent(menu.getComponent()); |
| | | children.setName(StringUtils.capitalize(menu.getPath())); |
| | | children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1" , menu.getIsCache()), menu.getPath())); |
| | | children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath())); |
| | | children.setQuery(menu.getQuery()); |
| | | childrenList.add(children); |
| | | router.setChildren(childrenList); |
| | |
| | | } |
| | | routers.add(router); |
| | | } |
| | | log.error("----------routers的入参为:{}",routers); |
| | | log.error("----------routers的入参为:{}", routers); |
| | | for (RouterVo routerVo : routers) { |
| | | List<String> childName = new ArrayList<>(); |
| | | List<RouterVo> childrens = routerVo.getChildren(); |
| | |
| | | * @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[]{"", "", "", "/"}); |
| | | } |
| | | } |