fix: 超级管理员不显示新增的菜单

之前显示因为系统管理员角色绑定菜单,超级管理员查询的时候无视条件查询的是系统管理员和其他角色绑定的菜单合集
This commit is contained in:
haoxr
2024-12-16 17:06:43 +08:00
parent eb0a96358e
commit fe163b7275
6 changed files with 51 additions and 141 deletions

View File

@@ -4,26 +4,8 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.youlai.boot.system.mapper.MenuMapper">
<!-- 菜单路由映射 -->
<resultMap id="RouteMap" type="com.youlai.boot.system.model.bo.RouteBO">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="parentId" column="parent_id" jdbcType="BIGINT"/>
<result property="routeName" column="route_name" jdbcType="VARCHAR"/>
<result property="routePath" column="route_path" jdbcType="VARCHAR"/>
<result property="component" column="component" jdbcType="VARCHAR"/>
<result property="redirect" column="redirect" jdbcType="VARCHAR"/>
<result property="icon" column="icon" jdbcType="VARCHAR"/>
<result property="sort" column="sort" jdbcType="INTEGER"/>
<result property="visible" column="visible" jdbcType="BOOLEAN"/>
<result property="type" column="type" jdbcType="OTHER"/>
<result property="alwaysShow" column="always_show" jdbcType="INTEGER"/>
<result property="keepAlive" column="keep_alive" jdbcType="INTEGER"/>
<result property="params" column="params" jdbcType="VARCHAR"/>
</resultMap>
<!-- 获取路由列表 -->
<select id="listRoutes" resultMap="RouteMap">
<select id="getMenusByRoleCodes" resultType="com.youlai.boot.system.model.entity.Menu">
SELECT
DISTINCT t1.id,
t1.name,
@@ -45,15 +27,17 @@
INNER JOIN sys_role t3 ON t2.role_id = t3.id AND t3.status = 1 AND t3.is_deleted = 0
WHERE
t1.type != '${@com.youlai.boot.system.enums.MenuTypeEnum@BUTTON.getValue()}'
<if test="roles != null and roles.size() > 0">
<!-- ROOT 可查看所有菜单 -->
<if test="!roles.contains('ROOT')">
<choose>
<when test="roleCodes != null and roleCodes.size() > 0">
AND t3.code IN
<foreach collection="roles" item="role" open="(" close=")" separator=",">
#{role}
<foreach item="roleCode" open="(" close=")" separator="," collection="roleCodes" >
#{roleCode}
</foreach>
</if>
</if>
</when>
<otherwise>
AND 1 = 0
</otherwise>
</choose>
ORDER BY
t1.sort
</select>