src/main/resources/mapper/system/SysMenuMapper.xml
@@ -11,6 +11,7 @@
      <result property="parentId"       column="parent_id"      />
      <result property="orderNum"       column="order_num"      />
      <result property="path"           column="path"           />
      <result property="appComponent"   column="app_component"  />
      <result property="component"      column="component"      />
      <result property="query"          column="query"          />
      <result property="routeName"      column="route_name"     />
@@ -29,8 +30,77 @@
   </resultMap>
   <sql id="selectMenuVo">
        select menu_id, menu_name, parent_id, order_num, path, component, `query`, route_name, is_frame, is_cache, menu_type, visible, status, ifnull(perms,'') as perms, icon, create_time
      from sys_menu
      WITH RECURSIVE valid_menus AS (
         SELECT
            menu_id,
            menu_name,
            parent_id,
            order_num,
            path,
            app_component,
            component,
            `query`,
            route_name,
            is_frame,
            is_cache,
            menu_type,
            visible,
            STATUS,
            IFNULL(perms, '') AS perms,
            icon,
            create_time,
            1 AS LEVEL
         FROM
            sys_menu
         WHERE
            STATUS = 0
           AND visible = 0
           AND (parent_id = 0 OR parent_id IS NULL) UNION ALL
         SELECT
            m.menu_id,
            m.menu_name,
            m.parent_id,
            m.order_num,
            m.path,
            m.app_component,
            m.component,
            m.`query`,
            m.route_name,
            m.is_frame,
            m.is_cache,
            m.menu_type,
            m.visible,
            m.STATUS,
            IFNULL(m.perms, '') AS perms,
            m.icon,
            m.create_time,
            vm.LEVEL + 1
         FROM
            sys_menu m
               INNER JOIN valid_menus vm ON m.parent_id = vm.menu_id
         WHERE
            m.STATUS = 0
           AND m.visible = 0
      ) SELECT
           menu_id,
           menu_name,
           parent_id,
           order_num,
           path,
           app_component,
           component,
           `query`,
           route_name,
           is_frame,
           is_cache,
           menu_type,
           visible,
           STATUS,
           perms,
           icon,
           create_time
      FROM
         valid_menus
    </sql>
    
    <select id="selectMenuList" parameterType="com.ruoyi.project.system.domain.SysMenu" resultMap="SysMenuResult">
@@ -50,13 +120,13 @@
   </select>
   
   <select id="selectMenuTreeAll" resultMap="SysMenuResult">
      select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, m.route_name, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
      select distinct m.menu_id, m.parent_id, m.menu_name, m.path,m.app_component, m.component, m.`query`, m.route_name, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
      from sys_menu m where m.menu_type in ('M', 'C') and m.status = 0
      order by m.parent_id, m.order_num
   </select>
   
   <select id="selectMenuListByUserId" parameterType="com.ruoyi.project.system.domain.SysMenu" resultMap="SysMenuResult">
      select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, m.route_name, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
      select distinct m.menu_id, m.parent_id, m.menu_name, m.path,m.app_component, m.component, m.`query`, m.route_name, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
      from sys_menu m
      left join sys_role_menu rm on m.menu_id = rm.menu_id
      left join sys_user_role ur on rm.role_id = ur.role_id
@@ -75,7 +145,7 @@
   </select>
    
    <select id="selectMenuTreeByUserId" parameterType="Long" resultMap="SysMenuResult">
      select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, m.route_name, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
      select distinct m.menu_id, m.parent_id, m.menu_name, m.path,m.app_component, m.component, m.`query`, m.route_name, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
      from sys_menu m
          left join sys_role_menu rm on m.menu_id = rm.menu_id
          left join sys_user_role ur on rm.role_id = ur.role_id
@@ -84,7 +154,7 @@
      where u.user_id = #{userId} and m.menu_type in ('M', 'C') and m.status = 0  AND ro.status = 0
      order by m.parent_id, m.order_num
   </select>
   <select id="selectMenuListByRoleId" resultType="Long">
      select m.menu_id
      from sys_menu m
@@ -132,7 +202,14 @@
      <include refid="selectMenuVo"/>
      where menu_name=#{menuName} and parent_id = #{parentId} limit 1
   </select>
   <select id="selectMenuByPath" resultType="com.ruoyi.project.system.domain.SysMenu" parameterType="java.lang.String">
        SELECT menu_id, menu_name, parent_id, path, app_component, status
        FROM sys_menu
        WHERE path = #{path}
          AND status = '0' LIMIT 1
    </select>
   <update id="updateMenu" parameterType="com.ruoyi.project.system.domain.SysMenu">
      update sys_menu
      <set>
@@ -141,6 +218,7 @@
         <if test="orderNum != null">order_num = #{orderNum},</if>
         <if test="path != null and path != ''">path = #{path},</if>
         <if test="component != null">component = #{component},</if>
          <if test="appComponent != null">app_component = #{appComponent},</if>
         <if test="query != null">`query` = #{query},</if>
         <if test="routeName != null">route_name = #{routeName},</if>
         <if test="isFrame != null and isFrame != ''">is_frame = #{isFrame},</if>
@@ -164,6 +242,7 @@
      <if test="menuName != null and menuName != ''">menu_name,</if>
      <if test="orderNum != null">order_num,</if>
      <if test="path != null and path != ''">path,</if>
      <if test="appComponent != null and appComponent != ''">app_component,</if>
      <if test="component != null and component != ''">component,</if>
      <if test="query != null and query != ''">`query`,</if>
      <if test="routeName != null">route_name,</if>
@@ -183,6 +262,7 @@
      <if test="menuName != null and menuName != ''">#{menuName},</if>
      <if test="orderNum != null">#{orderNum},</if>
      <if test="path != null and path != ''">#{path},</if>
      <if test="appComponent != null and appComponent != ''">#{appComponent},</if>
      <if test="component != null and component != ''">#{component},</if>
      <if test="query != null and query != ''">#{query},</if>
      <if test="routeName != null">#{routeName},</if>