vue2
This commit is contained in:
parent
3fce3766bb
commit
ec3b56a273
|
|
@ -45,8 +45,8 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter
|
||||||
String token = request.getHeader("Authorization");
|
String token = request.getHeader("Authorization");
|
||||||
String url =request.getRequestURI();
|
String url =request.getRequestURI();
|
||||||
// log.info("intercept " + url);
|
// log.info("intercept " + url);
|
||||||
// log.info("token: " + token);
|
// log.info("token: " + token); || request.getRequestURI().equals("/getInfo") || request.getRequestURI().equals("/logout")
|
||||||
if(request.getRequestURI().equals("/login") || request.getRequestURI().equals("/getInfo") || request.getRequestURI().equals("/logout")){
|
if(request.getRequestURI().equals("/login") ){
|
||||||
// 登录页面,放行
|
// 登录页面,放行
|
||||||
chain.doFilter(request, response);
|
chain.doFilter(request, response);
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,107 @@
|
||||||
|
package com.qihang.security.vo;
|
||||||
|
|
||||||
|
|
||||||
|
import com.qihang.common.utils.StringUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 路由显示信息
|
||||||
|
*
|
||||||
|
* @author qihang
|
||||||
|
*/
|
||||||
|
public class MetaVo
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 设置该路由在侧边栏和面包屑中展示的名字
|
||||||
|
*/
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置该路由的图标,对应路径src/assets/icons/svg
|
||||||
|
*/
|
||||||
|
private String icon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置为true,则不会被 <keep-alive>缓存
|
||||||
|
*/
|
||||||
|
private boolean noCache;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内链地址(http(s)://开头)
|
||||||
|
*/
|
||||||
|
private String link;
|
||||||
|
|
||||||
|
public MetaVo()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public MetaVo(String title, String icon)
|
||||||
|
{
|
||||||
|
this.title = title;
|
||||||
|
this.icon = icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MetaVo(String title, String icon, boolean noCache)
|
||||||
|
{
|
||||||
|
this.title = title;
|
||||||
|
this.icon = icon;
|
||||||
|
this.noCache = noCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MetaVo(String title, String icon, String link)
|
||||||
|
{
|
||||||
|
this.title = title;
|
||||||
|
this.icon = icon;
|
||||||
|
this.link = link;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MetaVo(String title, String icon, boolean noCache, String link)
|
||||||
|
{
|
||||||
|
this.title = title;
|
||||||
|
this.icon = icon;
|
||||||
|
this.noCache = noCache;
|
||||||
|
if (StringUtils.ishttp(link))
|
||||||
|
{
|
||||||
|
this.link = link;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isNoCache()
|
||||||
|
{
|
||||||
|
return noCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNoCache(boolean noCache)
|
||||||
|
{
|
||||||
|
this.noCache = noCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle()
|
||||||
|
{
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title)
|
||||||
|
{
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIcon()
|
||||||
|
{
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIcon(String icon)
|
||||||
|
{
|
||||||
|
this.icon = icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLink()
|
||||||
|
{
|
||||||
|
return link;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLink(String link)
|
||||||
|
{
|
||||||
|
this.link = link;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,147 @@
|
||||||
|
package com.qihang.security.vo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 路由配置信息
|
||||||
|
*
|
||||||
|
* @author qihang
|
||||||
|
*/
|
||||||
|
//@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||||
|
public class RouterVo
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 路由名字
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 路由地址
|
||||||
|
*/
|
||||||
|
private String path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否隐藏路由,当设置 true 的时候该路由不会再侧边栏出现
|
||||||
|
*/
|
||||||
|
private boolean hidden;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重定向地址,当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
|
||||||
|
*/
|
||||||
|
private String redirect;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组件地址
|
||||||
|
*/
|
||||||
|
private String component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 路由参数:如 {"id": 1, "name": "ry"}
|
||||||
|
*/
|
||||||
|
private String query;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当你一个路由下面的 children 声明的路由大于1个时,自动会变成嵌套的模式--如组件页面
|
||||||
|
*/
|
||||||
|
private Boolean alwaysShow;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 其他元素
|
||||||
|
*/
|
||||||
|
private MetaVo meta;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 子路由
|
||||||
|
*/
|
||||||
|
private List<RouterVo> children;
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPath()
|
||||||
|
{
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPath(String path)
|
||||||
|
{
|
||||||
|
this.path = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getHidden()
|
||||||
|
{
|
||||||
|
return hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHidden(boolean hidden)
|
||||||
|
{
|
||||||
|
this.hidden = hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRedirect()
|
||||||
|
{
|
||||||
|
return redirect;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRedirect(String redirect)
|
||||||
|
{
|
||||||
|
this.redirect = redirect;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getComponent()
|
||||||
|
{
|
||||||
|
return component;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setComponent(String component)
|
||||||
|
{
|
||||||
|
this.component = component;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getQuery()
|
||||||
|
{
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQuery(String query)
|
||||||
|
{
|
||||||
|
this.query = query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getAlwaysShow()
|
||||||
|
{
|
||||||
|
return alwaysShow;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAlwaysShow(Boolean alwaysShow)
|
||||||
|
{
|
||||||
|
this.alwaysShow = alwaysShow;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MetaVo getMeta()
|
||||||
|
{
|
||||||
|
return meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMeta(MetaVo meta)
|
||||||
|
{
|
||||||
|
this.meta = meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<RouterVo> getChildren()
|
||||||
|
{
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChildren(List<RouterVo> children)
|
||||||
|
{
|
||||||
|
this.children = children;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -86,11 +86,11 @@ public class SysLoginController
|
||||||
*
|
*
|
||||||
* @return 路由信息
|
* @return 路由信息
|
||||||
*/
|
*/
|
||||||
// @GetMapping("getRouters")
|
@GetMapping("getRouters")
|
||||||
// public AjaxResult getRouters()
|
public AjaxResult getRouters()
|
||||||
// {
|
{
|
||||||
// Long userId = SecurityUtils.getUserId();
|
Long userId = SecurityUtils.getUserId();
|
||||||
// List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
|
List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
|
||||||
// return AjaxResult.success(menuService.buildMenus(menus));
|
return AjaxResult.success(menuService.buildMenus(menus));
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.qihang.sys.api.service;
|
package com.qihang.sys.api.service;
|
||||||
|
|
||||||
|
import com.qihang.security.vo.RouterVo;
|
||||||
import com.qihang.sys.api.domain.SysMenu;
|
import com.qihang.sys.api.domain.SysMenu;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -51,7 +52,7 @@ public interface ISysMenuService
|
||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
* @return 菜单列表
|
* @return 菜单列表
|
||||||
*/
|
*/
|
||||||
// public List<SysMenu> selectMenuTreeByUserId(Long userId);
|
public List<SysMenu> selectMenuTreeByUserId(Long userId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据角色ID查询菜单树信息
|
* 根据角色ID查询菜单树信息
|
||||||
|
|
@ -67,7 +68,7 @@ public interface ISysMenuService
|
||||||
* @param menus 菜单列表
|
* @param menus 菜单列表
|
||||||
* @return 路由列表
|
* @return 路由列表
|
||||||
*/
|
*/
|
||||||
// public List<RouterVo> buildMenus(List<SysMenu> menus);
|
public List<RouterVo> buildMenus(List<SysMenu> menus);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建前端所需要树结构
|
* 构建前端所需要树结构
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,9 @@ package com.qihang.sys.api.service.impl;
|
||||||
|
|
||||||
import com.qihang.common.constant.UserConstants;
|
import com.qihang.common.constant.UserConstants;
|
||||||
import com.qihang.common.utils.StringUtils;
|
import com.qihang.common.utils.StringUtils;
|
||||||
|
import com.qihang.security.vo.MetaVo;
|
||||||
|
import com.qihang.security.vo.RouterVo;
|
||||||
|
import com.qihang.sys.api.common.SecurityUtils;
|
||||||
import com.qihang.sys.api.constant.Constants;
|
import com.qihang.sys.api.constant.Constants;
|
||||||
import com.qihang.sys.api.domain.SysMenu;
|
import com.qihang.sys.api.domain.SysMenu;
|
||||||
import com.qihang.sys.api.mapper.SysMenuMapper;
|
import com.qihang.sys.api.mapper.SysMenuMapper;
|
||||||
|
|
@ -104,26 +107,28 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||||
return permsSet;
|
return permsSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户ID查询菜单
|
* 根据用户ID查询菜单
|
||||||
*
|
*
|
||||||
* @param userId 用户名称
|
* @param userId 用户名称
|
||||||
* @return 菜单列表
|
* @return 菜单列表
|
||||||
*/
|
*/
|
||||||
// @Override
|
@Override
|
||||||
// public List<SysMenu> selectMenuTreeByUserId(Long userId)
|
public List<SysMenu> selectMenuTreeByUserId(Long userId)
|
||||||
// {
|
{
|
||||||
// List<SysMenu> menus = null;
|
List<SysMenu> menus = null;
|
||||||
// if (SecurityUtils.isAdmin(userId))
|
if (SecurityUtils.isAdmin(userId))
|
||||||
// {
|
{
|
||||||
// menus = menuMapper.selectMenuTreeAll();
|
menus = menuMapper.selectMenuTreeAll();
|
||||||
// }
|
}
|
||||||
// else
|
else
|
||||||
// {
|
{
|
||||||
// menus = menuMapper.selectMenuTreeByUserId(userId);
|
menus = menuMapper.selectMenuTreeByUserId(userId);
|
||||||
// }
|
}
|
||||||
// return getChildPerms(menus, 0);
|
return getChildPerms(menus, 0);
|
||||||
// }
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据角色ID查询菜单树信息
|
* 根据角色ID查询菜单树信息
|
||||||
|
|
@ -144,57 +149,57 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||||
* @param menus 菜单列表
|
* @param menus 菜单列表
|
||||||
* @return 路由列表
|
* @return 路由列表
|
||||||
*/
|
*/
|
||||||
// @Override
|
@Override
|
||||||
// public List<RouterVo> buildMenus(List<SysMenu> menus)
|
public List<RouterVo> buildMenus(List<SysMenu> menus)
|
||||||
// {
|
{
|
||||||
// List<RouterVo> routers = new LinkedList<RouterVo>();
|
List<RouterVo> routers = new LinkedList<RouterVo>();
|
||||||
// for (SysMenu menu : menus)
|
for (SysMenu menu : menus)
|
||||||
// {
|
{
|
||||||
// RouterVo router = new RouterVo();
|
RouterVo router = new RouterVo();
|
||||||
// router.setHidden("1".equals(menu.getVisible()));
|
router.setHidden("1".equals(menu.getVisible()));
|
||||||
// router.setName(getRouteName(menu));
|
router.setName(getRouteName(menu));
|
||||||
// router.setPath(getRouterPath(menu));
|
router.setPath(getRouterPath(menu));
|
||||||
// router.setComponent(getComponent(menu));
|
router.setComponent(getComponent(menu));
|
||||||
// router.setQuery(menu.getQuery());
|
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();
|
List<SysMenu> cMenus = menu.getChildren();
|
||||||
// if (StringUtils.isNotEmpty(cMenus) && UserConstants.TYPE_DIR.equals(menu.getMenuType()))
|
if (StringUtils.isNotEmpty(cMenus) && UserConstants.TYPE_DIR.equals(menu.getMenuType()))
|
||||||
// {
|
{
|
||||||
// router.setAlwaysShow(true);
|
router.setAlwaysShow(true);
|
||||||
// router.setRedirect("noRedirect");
|
router.setRedirect("noRedirect");
|
||||||
// router.setChildren(buildMenus(cMenus));
|
router.setChildren(buildMenus(cMenus));
|
||||||
// }
|
}
|
||||||
// else if (isMenuFrame(menu))
|
else if (isMenuFrame(menu))
|
||||||
// {
|
{
|
||||||
// router.setMeta(null);
|
router.setMeta(null);
|
||||||
// List<RouterVo> childrenList = new ArrayList<RouterVo>();
|
List<RouterVo> childrenList = new ArrayList<RouterVo>();
|
||||||
// RouterVo children = new RouterVo();
|
RouterVo children = new RouterVo();
|
||||||
// children.setPath(menu.getPath());
|
children.setPath(menu.getPath());
|
||||||
// children.setComponent(menu.getComponent());
|
children.setComponent(menu.getComponent());
|
||||||
// children.setName(StringUtils.capitalize(menu.getPath()));
|
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());
|
children.setQuery(menu.getQuery());
|
||||||
// childrenList.add(children);
|
childrenList.add(children);
|
||||||
// router.setChildren(childrenList);
|
router.setChildren(childrenList);
|
||||||
// }
|
}
|
||||||
// else if (menu.getParentId().intValue() == 0 && isInnerLink(menu))
|
else if (menu.getParentId().intValue() == 0 && isInnerLink(menu))
|
||||||
// {
|
{
|
||||||
// router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon()));
|
router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon()));
|
||||||
// router.setPath("/");
|
router.setPath("/");
|
||||||
// List<RouterVo> childrenList = new ArrayList<RouterVo>();
|
List<RouterVo> childrenList = new ArrayList<RouterVo>();
|
||||||
// RouterVo children = new RouterVo();
|
RouterVo children = new RouterVo();
|
||||||
// String routerPath = innerLinkReplaceEach(menu.getPath());
|
String routerPath = innerLinkReplaceEach(menu.getPath());
|
||||||
// children.setPath(routerPath);
|
children.setPath(routerPath);
|
||||||
// children.setComponent(UserConstants.INNER_LINK);
|
children.setComponent(UserConstants.INNER_LINK);
|
||||||
// children.setName(StringUtils.capitalize(routerPath));
|
children.setName(StringUtils.capitalize(routerPath));
|
||||||
// children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), menu.getPath()));
|
children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), menu.getPath()));
|
||||||
// childrenList.add(children);
|
childrenList.add(children);
|
||||||
// router.setChildren(childrenList);
|
router.setChildren(childrenList);
|
||||||
// }
|
}
|
||||||
// routers.add(router);
|
routers.add(router);
|
||||||
// }
|
}
|
||||||
// return routers;
|
return routers;
|
||||||
// }
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建前端所需要树结构
|
* 构建前端所需要树结构
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import request from '@/utils/request'
|
||||||
// 获取路由
|
// 获取路由
|
||||||
export const getRouters = () => {
|
export const getRouters = () => {
|
||||||
return request({
|
return request({
|
||||||
url: '/getRouters',
|
url: '/api/sys-api/getRouters',
|
||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue