mirror of
https://gitee.com/youlaitech/youlai-mall.git
synced 2024-12-22 20:54:26 +08:00
refactor: 用户拥有的菜单路由权限判断移至后台
This commit is contained in:
parent
5df0175e03
commit
ed51889870
@ -22,5 +22,5 @@ public interface SysMenuMapper extends BaseMapper<SysMenu> {
|
||||
/**
|
||||
* 获取菜单路由列表
|
||||
*/
|
||||
List<RouteBO> listRoutes(Set<String> routes);
|
||||
List<RouteBO> listRoutes(Set<String> roles);
|
||||
}
|
||||
|
@ -1,21 +1,14 @@
|
||||
package com.youlai.system.model.bo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.youlai.system.enums.MenuTypeEnum;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 路由
|
||||
*/
|
||||
@Data
|
||||
public class RouteBO {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
@ -29,14 +22,19 @@ public class RouteBO {
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 菜单类型(1-菜单;2-目录;3-外链;4-按钮权限)
|
||||
* 菜单类型(1-菜单 2-目录 3-外链 4-按钮)
|
||||
*/
|
||||
private MenuTypeEnum type;
|
||||
|
||||
/**
|
||||
* 路由路径(浏览器地址栏路径)
|
||||
* 路由名称(Vue Router 中定义的路由名称)
|
||||
*/
|
||||
private String path;
|
||||
private String routeName;
|
||||
|
||||
/**
|
||||
* 路由路径(Vue Router 中定义的 URL 路径)
|
||||
*/
|
||||
private String routePath;
|
||||
|
||||
/**
|
||||
* 组件路径(vue页面完整路径,省略.vue后缀)
|
||||
@ -68,11 +66,6 @@ public class RouteBO {
|
||||
*/
|
||||
private String redirect;
|
||||
|
||||
/**
|
||||
* 拥有路由的权限
|
||||
*/
|
||||
private List<String> roles;
|
||||
|
||||
/**
|
||||
* 【目录】只有一个子路由是否始终显示(1:是 0:否)
|
||||
*/
|
||||
|
@ -37,10 +37,15 @@ public class SysMenu{
|
||||
*/
|
||||
private MenuTypeEnum type;
|
||||
|
||||
/**
|
||||
* 路由名称(Vue Router 中定义的路由名称)
|
||||
*/
|
||||
private String routeName;
|
||||
|
||||
/**
|
||||
* 路由路径(浏览器地址栏路径)
|
||||
*/
|
||||
private String path;
|
||||
private String routePath;
|
||||
|
||||
/**
|
||||
* 组件路径(vue页面完整路径,省略.vue后缀)
|
||||
|
@ -11,6 +11,7 @@ import java.util.List;
|
||||
@Data
|
||||
public class MenuVO {
|
||||
|
||||
|
||||
@Schema(description = "菜单ID")
|
||||
private Long id;
|
||||
|
||||
@ -23,8 +24,11 @@ public class MenuVO {
|
||||
@Schema(description="菜单类型")
|
||||
private MenuTypeEnum type;
|
||||
|
||||
@Schema(description = "路由名称")
|
||||
private String routeName;
|
||||
|
||||
@Schema(description = "路由路径")
|
||||
private String path;
|
||||
private String routePath;
|
||||
|
||||
@Schema(description = "组件路径")
|
||||
private String component;
|
||||
|
@ -18,6 +18,7 @@ import java.util.Map;
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
public class RouteVO {
|
||||
|
||||
|
||||
@Schema(description = "路由路径", example = "user")
|
||||
private String path;
|
||||
|
||||
@ -46,9 +47,6 @@ public class RouteVO {
|
||||
@Schema(description = "是否隐藏(true-是 false-否)", example = "true")
|
||||
private Boolean hidden;
|
||||
|
||||
@Schema(description = "拥有路由权限的角色编码", example = "['ADMIN','ROOT']")
|
||||
private List<String> roles;
|
||||
|
||||
@Schema(description = "【菜单】是否开启页面缓存", example = "true")
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private Boolean keepAlive;
|
||||
|
@ -33,7 +33,7 @@ import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 菜单业务实现类
|
||||
* 菜单服务实现类
|
||||
*
|
||||
* @author Ray
|
||||
* @since 2020/11/06
|
||||
@ -171,19 +171,22 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
*/
|
||||
private RouteVO toRouteVo(RouteBO routeBO) {
|
||||
RouteVO routeVO = new RouteVO();
|
||||
// 路由名称 将path转换为驼峰命名 user => User
|
||||
String routeName = StringUtils.capitalize(StrUtil.toCamelCase(routeBO.getPath(), '-'));
|
||||
// 获取路由名称
|
||||
String routeName = routeBO.getRouteName();
|
||||
if (StrUtil.isBlank(routeName)) {
|
||||
// 路由 name 需要驼峰,首字母大写
|
||||
routeName = StringUtils.capitalize(StrUtil.toCamelCase(routeBO.getRoutePath(), '-'));
|
||||
}
|
||||
// 根据name路由跳转 this.$router.push({name:xxx})
|
||||
routeVO.setName(routeName);
|
||||
// 根据path路由跳转 this.$router.push({path:xxx})
|
||||
routeVO.setPath(routeBO.getPath());
|
||||
routeVO.setPath(routeBO.getRoutePath());
|
||||
routeVO.setRedirect(routeBO.getRedirect());
|
||||
routeVO.setComponent(routeBO.getComponent());
|
||||
|
||||
RouteVO.Meta meta = new RouteVO.Meta();
|
||||
meta.setTitle(routeBO.getName());
|
||||
meta.setIcon(routeBO.getIcon());
|
||||
meta.setRoles(routeBO.getRoles());
|
||||
meta.setHidden(StatusEnum.DISABLE.getValue().equals(routeBO.getVisible()));
|
||||
// 【菜单】是否开启页面缓存
|
||||
if (MenuTypeEnum.MENU.equals(routeBO.getType())
|
||||
|
Loading…
Reference in New Issue
Block a user