瀏覽代碼

登陆时获取菜单权限接口修改getUserPermissionByToken

sl 10 月之前
父節點
當前提交
11d3a1f284

+ 409 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/interlockUser/controller/InterlockUserRolePermissionController.java

@@ -0,0 +1,409 @@
+package org.jeecg.modules.interlockUser.controller;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.SecurityUtils;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.constant.CommonConstant;
+import org.jeecg.common.constant.SymbolConstant;
+import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.common.util.Md5Util;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.config.JeecgBaseConfig;
+import org.jeecg.modules.interlockUser.entity.InterlockUser;
+import org.jeecg.modules.interlockUser.mapper.InterlockUserMapper;
+import org.jeecg.modules.interlockUser.service.IInterlockUserRolePermissionService;
+import org.jeecg.modules.system.controller.SysPermissionController;
+import org.jeecg.modules.system.entity.SysPermission;
+import org.jeecg.modules.system.entity.SysRoleIndex;
+import org.jeecg.modules.system.service.ISysPermissionService;
+import org.jeecg.modules.system.service.ISysUserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * ClassName: InterlockUserRolePermissionController
+ * Package: org.jeecg.modules.interlockUser.controller
+ * Description:  改写系统的用户角色获取菜单权限接口
+ *
+ * @Author sl
+ * @Create 2024/8/6 15:43
+ * @Version 1.0
+ */
+@RestController
+@RequestMapping("/interlockUser/interlockUser")
+@Slf4j
+public class InterlockUserRolePermissionController {
+    @Autowired
+    @SuppressWarnings("all")
+    private JeecgBaseConfig jeecgBaseConfig;
+
+    @Autowired
+    @SuppressWarnings("all")
+    private ISysUserService sysUserService;
+
+    @Autowired
+    @SuppressWarnings("all")
+    private SysPermissionController sysPermissionController;
+
+    @Autowired
+    @SuppressWarnings("all")
+    private ISysPermissionService sysPermissionService;
+
+    @Autowired
+    @SuppressWarnings("all")
+    private InterlockUserMapper interlockUserMapper;
+
+    @Autowired
+    @SuppressWarnings("all")
+    private IInterlockUserRolePermissionService interlockUserRolePermissionService;
+
+    /**
+     * 子菜单
+     */
+    private static final String CHILDREN = "children";
+
+    /**
+     * 查询用户拥有的菜单权限和按钮权限
+     *
+     * @return
+     */
+    @RequestMapping(value = "/getInterlockUserPermissionByToken", method = RequestMethod.GET)
+    //@DynamicTable(value = DynamicTableConstant.SYS_ROLE_INDEX)
+    @ApiOperation("查询用户拥有的菜单权限和按钮权限")
+    public Result<?> getInterlockUserPermissionByToken(HttpServletRequest request) {
+        Result<JSONObject> result = new Result<JSONObject>();
+        String wiseUser = "";
+        try {
+            //获取当前用户名
+            Cookie[] cookies = request.getCookies();
+            if (cookies != null) {
+                for (Cookie cookie : cookies) {
+                    if (cookie.getName().equals("WISEUser")) {
+                        wiseUser = cookie.getValue();
+                    }
+                }
+            }
+//            wiseUser = "测试用户2";
+            if (wiseUser.equals("")) return Result.error("请登录系统!");
+
+            //直接获取当前用户不适用前端token
+            InterlockUser interlockUser = interlockUserMapper.getInterlockUserByUserName(wiseUser);
+//            LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+            if (oConvertUtils.isEmpty(interlockUser)) {
+                return Result.error("请登录系统!");
+            }
+            List<SysPermission> metaList = interlockUserRolePermissionService.queryByUser(wiseUser);
+//            System.out.println(metaList);
+            //update-begin--Author:zyf Date:20220425  for:自定义首页地址 LOWCOD-1578
+            String version = request.getHeader(CommonConstant.VERSION);
+            //update-begin---author:liusq ---date:2022-06-29  for:接口返回值修改,同步修改这里的判断逻辑-----------
+            SysRoleIndex roleIndex= interlockUserRolePermissionService.getDynamicIndexByUserRole(wiseUser,version);
+            System.out.println(roleIndex);
+            //update-end---author:liusq ---date:2022-06-29  for:接口返回值修改,同步修改这里的判断逻辑-----------
+            //update-end--Author:zyf  Date:20220425  for:自定义首页地址 LOWCOD-1578
+
+            if(roleIndex!=null){
+                List<SysPermission> menus = metaList.stream().filter(sysPermission -> "首页".equals(sysPermission.getName())).collect(Collectors.toList());
+                //update-begin---author:liusq ---date:2022-06-29  for:设置自定义首页地址和组件----------
+                String component = roleIndex.getComponent();
+                String routeUrl = roleIndex.getUrl();
+                boolean route = roleIndex.isRoute();
+                if(oConvertUtils.isNotEmpty(routeUrl)){
+                    menus.get(0).setComponent(component);
+                    menus.get(0).setRoute(route);
+                    menus.get(0).setUrl(routeUrl);
+                }else{
+                    menus.get(0).setComponent(component);
+                }
+                //update-end---author:liusq ---date:2022-06-29  for:设置自定义首页地址和组件-----------
+            }
+
+            JSONObject json = new JSONObject();
+            JSONArray menujsonArray = new JSONArray();
+            this.getPermissionJsonArray(menujsonArray, metaList, null);
+            //一级菜单下的子菜单全部是隐藏路由,则一级菜单不显示
+            this.handleFirstLevelMenuHidden(menujsonArray);
+
+            JSONArray authjsonArray = new JSONArray();
+            this.getAuthJsonArray(authjsonArray, metaList);
+            //查询所有的权限
+            LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>();
+            query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
+            query.eq(SysPermission::getMenuType, CommonConstant.MENU_TYPE_2);
+            //query.eq(SysPermission::getStatus, "1");
+            List<SysPermission> allAuthList = sysPermissionService.list(query);
+            JSONArray allauthjsonArray = new JSONArray();
+            this.getAllAuthJsonArray(allauthjsonArray, allAuthList);
+            //路由菜单
+            json.put("menu", menujsonArray);
+            //按钮权限(用户拥有的权限集合)
+            json.put("auth", authjsonArray);
+            //全部权限配置集合(按钮权限,访问权限)
+            json.put("allAuth", allauthjsonArray);
+            json.put("sysSafeMode", jeecgBaseConfig.getSafeMode());
+            result.setResult(json);
+        } catch (Exception e) {
+            result.error500("查询失败:" + e.getMessage());
+            log.error(e.getMessage(), e);
+        }
+        return result;
+    }
+
+    /**
+     *  获取菜单JSON数组
+     * @param jsonArray
+     * @param metaList
+     * @param parentJson
+     */
+    private void getPermissionJsonArray(JSONArray jsonArray, List<SysPermission> metaList, JSONObject parentJson) {
+        for (SysPermission permission : metaList) {
+            if (permission.getMenuType() == null) {
+                continue;
+            }
+            String tempPid = permission.getParentId();
+            JSONObject json = getPermissionJsonObject(permission);
+            if(json==null) {
+                continue;
+            }
+            if (parentJson == null && oConvertUtils.isEmpty(tempPid)) {
+                jsonArray.add(json);
+                if (!permission.isLeaf()) {
+                    getPermissionJsonArray(jsonArray, metaList, json);
+                }
+            } else if (parentJson != null && oConvertUtils.isNotEmpty(tempPid) && tempPid.equals(parentJson.getString("id"))) {
+                // 类型( 0:一级菜单 1:子菜单 2:按钮 )
+                if (permission.getMenuType().equals(CommonConstant.MENU_TYPE_2)) {
+                    JSONObject metaJson = parentJson.getJSONObject("meta");
+                    if (metaJson.containsKey("permissionList")) {
+                        metaJson.getJSONArray("permissionList").add(json);
+                    } else {
+                        JSONArray permissionList = new JSONArray();
+                        permissionList.add(json);
+                        metaJson.put("permissionList", permissionList);
+                    }
+                    // 类型( 0:一级菜单 1:子菜单 2:按钮 )
+                } else if (permission.getMenuType().equals(CommonConstant.MENU_TYPE_1) || permission.getMenuType().equals(CommonConstant.MENU_TYPE_0)) {
+                    if (parentJson.containsKey("children")) {
+                        parentJson.getJSONArray("children").add(json);
+                    } else {
+                        JSONArray children = new JSONArray();
+                        children.add(json);
+                        parentJson.put("children", children);
+                    }
+
+                    if (!permission.isLeaf()) {
+                        getPermissionJsonArray(jsonArray, metaList, json);
+                    }
+                }
+            }
+
+        }
+    }
+
+    /**
+     * 根据菜单配置生成路由json
+     * @param permission
+     * @return
+     */
+    private JSONObject getPermissionJsonObject(SysPermission permission) {
+        JSONObject json = new JSONObject();
+        // 类型(0:一级菜单 1:子菜单 2:按钮)
+        if (permission.getMenuType().equals(CommonConstant.MENU_TYPE_2)) {
+            //json.put("action", permission.getPerms());
+            //json.put("type", permission.getPermsType());
+            //json.put("describe", permission.getName());
+            return null;
+        } else if (permission.getMenuType().equals(CommonConstant.MENU_TYPE_0) || permission.getMenuType().equals(CommonConstant.MENU_TYPE_1)) {
+            json.put("id", permission.getId());
+            if (permission.isRoute()) {
+                //表示生成路由
+                json.put("route", "1");
+            } else {
+                //表示不生成路由
+                json.put("route", "0");
+            }
+
+            if (isWwwHttpUrl(permission.getUrl())) {
+                json.put("path", Md5Util.md5Encode(permission.getUrl(), "utf-8"));
+            } else {
+                json.put("path", permission.getUrl());
+            }
+
+            // 重要规则:路由name (通过URL生成路由name,路由name供前端开发,页面跳转使用)
+            if (oConvertUtils.isNotEmpty(permission.getComponentName())) {
+                json.put("name", permission.getComponentName());
+            } else {
+                json.put("name", urlToRouteName(permission.getUrl()));
+            }
+
+            JSONObject meta = new JSONObject();
+            // 是否隐藏路由,默认都是显示的
+            if (permission.isHidden()) {
+                json.put("hidden", true);
+                //vue3版本兼容代码
+                meta.put("hideMenu",true);
+            }
+            // 聚合路由
+            if (permission.isAlwaysShow()) {
+                json.put("alwaysShow", true);
+            }
+            json.put("component", permission.getComponent());
+            // 由用户设置是否缓存页面 用布尔值
+            if (permission.isKeepAlive()) {
+                meta.put("keepAlive", true);
+            } else {
+                meta.put("keepAlive", false);
+            }
+
+            /*update_begin author:wuxianquan date:20190908 for:往菜单信息里添加外链菜单打开方式 */
+            //外链菜单打开方式
+            if (permission.isInternalOrExternal()) {
+                meta.put("internalOrExternal", true);
+            } else {
+                meta.put("internalOrExternal", false);
+            }
+            /* update_end author:wuxianquan date:20190908 for: 往菜单信息里添加外链菜单打开方式*/
+
+            meta.put("title", permission.getName());
+
+            //update-begin--Author:scott  Date:20201015 for:路由缓存问题,关闭了tab页时再打开就不刷新 #842
+            String component = permission.getComponent();
+            if(oConvertUtils.isNotEmpty(permission.getComponentName()) || oConvertUtils.isNotEmpty(component)){
+                meta.put("componentName", oConvertUtils.getString(permission.getComponentName(),component.substring(component.lastIndexOf("/")+1)));
+            }
+            //update-end--Author:scott  Date:20201015 for:路由缓存问题,关闭了tab页时再打开就不刷新 #842
+
+            if (oConvertUtils.isEmpty(permission.getParentId())) {
+                // 一级菜单跳转地址
+                json.put("redirect", permission.getRedirect());
+                if (oConvertUtils.isNotEmpty(permission.getIcon())) {
+                    meta.put("icon", permission.getIcon());
+                }
+            } else {
+                if (oConvertUtils.isNotEmpty(permission.getIcon())) {
+                    meta.put("icon", permission.getIcon());
+                }
+            }
+            if (isWwwHttpUrl(permission.getUrl())) {
+                meta.put("url", permission.getUrl());
+            }
+            // update-begin--Author:sunjianlei  Date:20210918 for:新增适配vue3项目的隐藏tab功能
+            if (permission.isHideTab()) {
+                meta.put("hideTab", true);
+            }
+            // update-end--Author:sunjianlei  Date:20210918 for:新增适配vue3项目的隐藏tab功能
+            json.put("meta", meta);
+        }
+
+        return json;
+    }
+
+    /**
+     * 判断是否外网URL 例如: http://localhost:8080/jeecg-boot/swagger-ui.html#/ 支持特殊格式: {{
+     * window._CONFIG['domianURL'] }}/druid/ {{ JS代码片段 }},前台解析会自动执行JS代码片段
+     *
+     * @return
+     */
+    private boolean isWwwHttpUrl(String url) {
+        boolean flag = url != null && (url.startsWith(CommonConstant.HTTP_PROTOCOL) || url.startsWith(CommonConstant.HTTPS_PROTOCOL) || url.startsWith(SymbolConstant.DOUBLE_LEFT_CURLY_BRACKET));
+        if (flag) {
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * 通过URL生成路由name(去掉URL前缀斜杠,替换内容中的斜杠‘/’为-) 举例: URL = /isystem/role RouteName =
+     * isystem-role
+     *
+     * @return
+     */
+    private String urlToRouteName(String url) {
+        if (oConvertUtils.isNotEmpty(url)) {
+            if (url.startsWith(SymbolConstant.SINGLE_SLASH)) {
+                url = url.substring(1);
+            }
+            url = url.replace("/", "-");
+
+            // 特殊标记
+            url = url.replace(":", "@");
+            return url;
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * 一级菜单的子菜单全部是隐藏路由,则一级菜单不显示
+     * @param jsonArray
+     */
+    private void handleFirstLevelMenuHidden(JSONArray jsonArray) {
+        jsonArray = jsonArray.stream().map(obj -> {
+            JSONObject returnObj = new JSONObject();
+            JSONObject jsonObj = (JSONObject)obj;
+            if(jsonObj.containsKey(CHILDREN)){
+                JSONArray childrens = jsonObj.getJSONArray(CHILDREN);
+                childrens = childrens.stream().filter(arrObj -> !"true".equals(((JSONObject) arrObj).getString("hidden"))).collect(Collectors.toCollection(JSONArray::new));
+                if(childrens==null || childrens.size()==0){
+                    jsonObj.put("hidden",true);
+
+                    //vue3版本兼容代码
+                    JSONObject meta = new JSONObject();
+                    meta.put("hideMenu",true);
+                    jsonObj.put("meta", meta);
+                }
+            }
+            return returnObj;
+        }).collect(Collectors.toCollection(JSONArray::new));
+    }
+
+    /**
+     *  获取权限JSON数组
+     * @param jsonArray
+     * @param metaList
+     */
+    private void getAuthJsonArray(JSONArray jsonArray,List<SysPermission> metaList) {
+        for (SysPermission permission : metaList) {
+            if(permission.getMenuType()==null) {
+                continue;
+            }
+            JSONObject json = null;
+            if(permission.getMenuType().equals(CommonConstant.MENU_TYPE_2) &&CommonConstant.STATUS_1.equals(permission.getStatus())) {
+                json = new JSONObject();
+                json.put("action", permission.getPerms());
+                json.put("type", permission.getPermsType());
+                json.put("describe", permission.getName());
+                jsonArray.add(json);
+            }
+        }
+    }
+
+    /**
+     *  获取权限JSON数组
+     * @param jsonArray
+     * @param allList
+     */
+    private void getAllAuthJsonArray(JSONArray jsonArray,List<SysPermission> allList) {
+        JSONObject json = null;
+        for (SysPermission permission : allList) {
+            json = new JSONObject();
+            json.put("action", permission.getPerms());
+            json.put("status", permission.getStatus());
+            //1显示2禁用
+            json.put("type", permission.getPermsType());
+            json.put("describe", permission.getName());
+            jsonArray.add(json);
+        }
+    }
+}

+ 4 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/interlockUser/mapper/InterlockUserMapper.java

@@ -3,6 +3,7 @@ package org.jeecg.modules.interlockUser.mapper;
 import java.util.List;
 
 import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
 import org.jeecg.modules.interlockUser.entity.InterlockUser;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
@@ -13,5 +14,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  * @Version: V1.0
  */
 public interface InterlockUserMapper extends BaseMapper<InterlockUser> {
+    //根据用户名查找用户信息
+    @Select("select * from interlock_user where username=#{wiseUser}")
+    InterlockUser getInterlockUserByUserName(@Param("wiseUser") String wiseUser);
 
 }

+ 35 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/interlockUser/mapper/InterlockUserRolePermissionMapper.java

@@ -0,0 +1,35 @@
+package org.jeecg.modules.interlockUser.mapper;
+
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.jeecg.modules.system.entity.SysPermission;
+
+import java.util.List;
+
+/**
+ * ClassName: InterlockUserRolePermissionMapper
+ * Package: org.jeecg.modules.interlockUser.mapper
+ * Description: 改写系统的用户角色获取菜单权限接口
+ *
+ * @Author sl
+ * @Create 2024/8/6 16:26
+ * @Version 1.0
+ */
+public interface InterlockUserRolePermissionMapper {
+
+    /**
+     * 根据用户查询用户权限
+     * @param username 用户账户名称
+     * @return List<SysPermission>
+     */
+    public List<SysPermission> queryByUser(@Param("username") String username);
+
+    /**
+     * 通过用户账号查询角色集合
+     * @param username 用户账号名称
+     * @return List<String>
+     */
+    @Select("select role_code from sys_role where id in (select role_id from sys_user_role where user_id = (select id from interlock_user where username=#{username}))")
+    List<String> getRoleByUserName(@Param("username") String username);
+
+}

+ 44 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/interlockUser/mapper/xml/InterlockUserRolePermissionMapper.xml

@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.jeecg.modules.interlockUser.mapper.InterlockUserRolePermissionMapper">
+    <!-- 通过<resultMap>映射实体类属性名和表的字段名对应关系 -->
+    <resultMap id="SysPermission" type="org.jeecg.modules.system.entity.SysPermission">
+        <!-- result属性映射非匹配字段 -->
+        <result column="is_route" property="route"/>
+        <result column="keep_alive" property="keepAlive"/>
+        <result column="is_leaf" property="leaf"/>
+    </resultMap>
+
+    <!-- 获取登录用户拥有的权限 -->
+    <select id="queryByUser" parameterType="Object"  resultMap="SysPermission">
+        SELECT * FROM (
+        SELECT p.*
+        FROM  sys_permission p
+        WHERE (exists(
+        select a.id from sys_role_permission a
+        join sys_role b on a.role_id = b.id
+        join sys_user_role c on c.role_id = b.id
+        join interlock_user d on d.id = c.user_id
+        where p.id = a.permission_id AND d.username = #{username,jdbcType=VARCHAR}
+        )
+        or (p.url like '%:code' and p.url like '/online%' and p.hidden = 1)
+        or (p.url like '%:id' and p.url like '/online%' and p.hidden = 1)
+        or p.url = '/online')
+        and p.del_flag = 0
+        <!--update begin Author:lvdandan  Date:20200213 for:加入部门权限 -->
+        UNION
+        SELECT p.*
+        FROM  sys_permission p
+        WHERE exists(
+        select a.id from sys_depart_role_permission a
+        join sys_depart_role b on a.role_id = b.id
+        join sys_depart_role_user c on c.drole_id = b.id
+        join interlock_user d on d.id = c.user_id
+        where p.id = a.permission_id AND d.username = #{username,jdbcType=VARCHAR}
+        )
+        and p.del_flag = 0
+        <!--update end Author:lvdandan  Date:20200213 for:加入部门权限 -->
+        ) h order by h.sort_no ASC
+    </select>
+
+</mapper>

+ 35 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/interlockUser/service/IInterlockUserRolePermissionService.java

@@ -0,0 +1,35 @@
+package org.jeecg.modules.interlockUser.service;
+
+import org.jeecg.modules.system.entity.SysPermission;
+import org.jeecg.modules.system.entity.SysRoleIndex;
+
+import java.util.List;
+
+/**
+ * ClassName: IInterlockUserRolePermissionService
+ * Package: org.jeecg.modules.interlockUser.service
+ * Description:改写系统的用户角色获取菜单权限接口
+ *
+ * @Author sl
+ * @Create 2024/8/6 15:48
+ * @Version 1.0
+ */
+public interface IInterlockUserRolePermissionService {
+
+    /**
+     * 获取登录用户拥有的权限
+     * @param username 用户名
+     * @return
+     */
+    public List<SysPermission> queryByUser(String username);
+
+    /**
+     * 获取根据登录用户的角色获取动态首页
+     *
+     * @param username
+     * @param version 前端UI版本
+     * @return
+     */
+    public SysRoleIndex getDynamicIndexByUserRole(String username, String version);
+
+}

+ 81 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/interlockUser/service/impl/InterlockUserRolePermissionServiceImpl.java

@@ -0,0 +1,81 @@
+package org.jeecg.modules.interlockUser.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import org.checkerframework.checker.units.qual.A;
+import org.jeecg.common.constant.CommonConstant;
+import org.jeecg.common.constant.enums.RoleIndexConfigEnum;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.modules.interlockUser.mapper.InterlockUserRolePermissionMapper;
+import org.jeecg.modules.interlockUser.service.IInterlockUserRolePermissionService;
+import org.jeecg.modules.system.entity.SysPermission;
+import org.jeecg.modules.system.entity.SysRoleIndex;
+import org.jeecg.modules.system.mapper.SysRoleIndexMapper;
+import org.jeecg.modules.system.service.ISysRoleIndexService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * ClassName: InterlockUserRolePermissionServiceImpl
+ * Package: org.jeecg.modules.interlockUser.service.impl
+ * Description:改写系统的用户角色获取菜单权限接口
+ *
+ * @Author sl
+ * @Create 2024/8/6 15:51
+ * @Version 1.0
+ */
+@Service
+public class InterlockUserRolePermissionServiceImpl implements IInterlockUserRolePermissionService {
+
+    @Autowired
+    @SuppressWarnings("all")
+    private SysRoleIndexMapper sysRoleIndexMapper;
+
+    @Autowired
+    @SuppressWarnings("all")
+    private InterlockUserRolePermissionMapper interlockUserRolePermissionMapper;
+
+    /**
+     * 获取登录用户拥有的权限
+     * @param username 用户名
+     * @return
+     */
+    @Override
+    public List<SysPermission> queryByUser(String username) {
+        return this.interlockUserRolePermissionMapper.queryByUser(username);
+    }
+
+    /**
+     * 获取动态首页路由配置
+     * @param username
+     * @param version
+     * @return
+     */
+    @Override
+    public SysRoleIndex getDynamicIndexByUserRole(String username, String version) {
+        List<String> roles = interlockUserRolePermissionMapper.getRoleByUserName(username);
+        String componentUrl = RoleIndexConfigEnum.getIndexByRoles(roles);
+        SysRoleIndex roleIndex = new SysRoleIndex(componentUrl);
+        //只有 X-Version=v3 的时候,才读取sys_role_index表获取角色首页配置
+        if (oConvertUtils.isNotEmpty(version) && roles!=null && roles.size()>0) {
+            LambdaQueryWrapper<SysRoleIndex> routeIndexQuery = new LambdaQueryWrapper();
+            //用户所有角色
+            routeIndexQuery.in(SysRoleIndex::getRoleCode, roles);
+            //角色首页状态0:未开启  1:开启
+            routeIndexQuery.eq(SysRoleIndex::getStatus, CommonConstant.STATUS_1);
+            //优先级正序排序
+            routeIndexQuery.orderByAsc(SysRoleIndex::getPriority);
+            List<SysRoleIndex> list = sysRoleIndexMapper.selectList(routeIndexQuery);
+            if (null != list && list.size() > 0) {
+                roleIndex = list.get(0);
+            }
+        }
+
+        //如果componentUrl为空,则返回空
+        if(oConvertUtils.isEmpty(roleIndex.getComponent())){
+            return null;
+        }
+        return roleIndex;
+    }
+}