SysMenuMapper.xml 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.ruoyi.system.mapper.SysMenuMapper">
  6. <resultMap type="SysMenu" id="SysMenuResult">
  7. <id property="menuId" column="menu_id" />
  8. <result property="menuName" column="menu_name" />
  9. <result property="parentName" column="parent_name" />
  10. <result property="parentId" column="parent_id" />
  11. <result property="orderNum" column="order_num" />
  12. <result property="url" column="url" />
  13. <result property="target" column="target" />
  14. <result property="menuType" column="menu_type" />
  15. <result property="visible" column="visible" />
  16. <result property="isRefresh" column="is_refresh" />
  17. <result property="perms" column="perms" />
  18. <result property="icon" column="icon" />
  19. <result property="createBy" column="create_by" />
  20. <result property="createTime" column="create_time" />
  21. <result property="updateTime" column="update_time" />
  22. <result property="updateBy" column="update_by" />
  23. <result property="remark" column="remark" />
  24. </resultMap>
  25. <sql id="selectMenuVo">
  26. select menu_id, menu_name, parent_id, order_num, url, target, menu_type, visible, is_refresh, nvl(perms,'') as perms, icon, create_by, create_time
  27. from sys_menu
  28. </sql>
  29. <select id="selectMenusByUserId" parameterType="Long" resultMap="SysMenuResult">
  30. select distinct m.menu_id, m.parent_id, m.menu_name, m.url, m.visible, m.is_refresh, nvl(m.perms,'') as perms, m.target, m.menu_type, m.icon, m.order_num, m.create_time
  31. from sys_menu m
  32. left join sys_role_menu rm on m.menu_id = rm.menu_id
  33. left join sys_user_role ur on rm.role_id = ur.role_id
  34. LEFT JOIN sys_role ro on ur.role_id = ro.role_id
  35. where ur.user_id = #{userId} and m.menu_type in ('M', 'C') and m.visible = 0 AND ro.status = 0
  36. order by m.parent_id, m.order_num
  37. </select>
  38. <select id="selectMenuNormalAll" resultMap="SysMenuResult">
  39. select distinct m.menu_id, m.parent_id, m.menu_name, m.url, m.visible, m.is_refresh, nvl(m.perms,'') as perms, m.target, m.menu_type, m.icon, m.order_num, m.create_time
  40. from sys_menu m
  41. where m.menu_type in ('M', 'C') and m.visible = 0
  42. order by m.parent_id, m.order_num
  43. </select>
  44. <select id="selectMenuAll" resultMap="SysMenuResult">
  45. <include refid="selectMenuVo"/>
  46. order by parent_id, order_num
  47. </select>
  48. <select id="selectMenuAllByUserId" parameterType="Long" resultMap="SysMenuResult">
  49. select distinct m.menu_id, m.parent_id, m.menu_name, m.url, m.visible, m.is_refresh, nvl(m.perms,'') as perms, m.target, m.menu_type, m.icon, m.order_num, m.create_time
  50. from sys_menu m
  51. left join sys_role_menu rm on m.menu_id = rm.menu_id
  52. left join sys_user_role ur on rm.role_id = ur.role_id
  53. LEFT JOIN sys_role ro on ur.role_id = ro.role_id
  54. where ur.user_id = #{userId}
  55. order by m.parent_id, m.order_num
  56. </select>
  57. <select id="selectPermsByUserId" parameterType="Long" resultType="String">
  58. select distinct m.perms
  59. from sys_menu m
  60. left join sys_role_menu rm on m.menu_id = rm.menu_id
  61. left join sys_user_role ur on rm.role_id = ur.role_id
  62. left join sys_role r on r.role_id = ur.role_id
  63. where m.visible = '0' and r.status = '0' and ur.user_id = #{userId}
  64. </select>
  65. <select id="selectMenuTree" parameterType="Long" resultType="String">
  66. select concat(m.menu_id, nvl(m.perms,'')) as perms
  67. from sys_menu m
  68. left join sys_role_menu rm on m.menu_id = rm.menu_id
  69. where rm.role_id = #{roleId}
  70. order by m.parent_id, m.order_num
  71. </select>
  72. <select id="selectMenuList" parameterType="SysMenu" resultMap="SysMenuResult">
  73. <include refid="selectMenuVo"/>
  74. <where>
  75. <if test="menuName != null and menuName != ''">
  76. AND menu_name like concat(concat('%',#{menuName}),'%')
  77. </if>
  78. <if test="visible != null and visible != ''">
  79. AND visible = #{visible}
  80. </if>
  81. </where>
  82. order by parent_id, order_num
  83. </select>
  84. <select id="selectMenuListByUserId" parameterType="SysMenu" resultMap="SysMenuResult">
  85. select distinct m.menu_id, m.parent_id, m.menu_name, m.url, m.visible, m.is_refresh, nvl(m.perms,'') as perms, m.target, m.menu_type, m.icon, m.order_num, m.create_time
  86. from sys_menu m
  87. left join sys_role_menu rm on m.menu_id = rm.menu_id
  88. left join sys_user_role ur on rm.role_id = ur.role_id
  89. LEFT JOIN sys_role ro on ur.role_id = ro.role_id
  90. where ur.user_id = #{params.userId}
  91. <if test="menuName != null and menuName != ''">
  92. AND m.menu_name like concat(concat('%', #{menuName}), '%')
  93. </if>
  94. <if test="visible != null and visible != ''">
  95. AND m.visible = #{visible}
  96. </if>
  97. order by m.parent_id, m.order_num
  98. </select>
  99. <delete id="deleteMenuById" parameterType="Long">
  100. delete from sys_menu where menu_id = #{menuId} or parent_id = #{menuId}
  101. </delete>
  102. <select id="selectMenuById" parameterType="Long" resultMap="SysMenuResult">
  103. SELECT t.menu_id, t.parent_id, t.menu_name, t.order_num, t.url, t.target, t.menu_type, t.visible, t.is_refresh, t.perms, t.icon, t.remark,
  104. (SELECT menu_name FROM sys_menu WHERE menu_id = t.parent_id) parent_name
  105. FROM sys_menu t
  106. where t.menu_id = #{menuId}
  107. </select>
  108. <select id="selectCountMenuByParentId" resultType="Integer">
  109. select count(1) from sys_menu where parent_id=#{menuId}
  110. </select>
  111. <select id="checkMenuNameUnique" parameterType="SysMenu" resultMap="SysMenuResult">
  112. <include refid="selectMenuVo"/>
  113. where menu_name=#{menuName} and parent_id = #{parentId} and rownum <![CDATA[ <= ]]> 1
  114. </select>
  115. <select id="selectSysMenuList" parameterType="SysMenu" resultMap="SysMenuResult">
  116. <include refid="selectMenuVo"/>
  117. <where>
  118. <if test="menuName != null and menuName != ''">
  119. AND menu_name like concat(concat('%',#{menuName}),'%')
  120. </if>
  121. <if test="visible != null and visible != ''">
  122. AND visible = #{visible}
  123. </if>
  124. <if test="remark != null and remark != ''">
  125. AND remark = #{remark}
  126. </if>
  127. </where>
  128. </select>
  129. <update id="updateMenu" parameterType="SysMenu">
  130. update sys_menu
  131. <set>
  132. <if test="menuName != null and menuName != ''">menu_name = #{menuName},</if>
  133. <if test="parentId != null and parentId != 0">parent_id = #{parentId},</if>
  134. <if test="orderNum != null and orderNum != ''">order_num = #{orderNum},</if>
  135. <if test="url != null">url = #{url},</if>
  136. <if test="target != null and target != ''">target = #{target},</if>
  137. <if test="menuType != null and menuType != ''">menu_type = #{menuType},</if>
  138. <if test="visible != null">visible = #{visible},</if>
  139. <if test="isRefresh != null">is_refresh = #{isRefresh},</if>
  140. <if test="perms !=null">perms = #{perms},</if>
  141. <if test="icon !=null and icon != ''">icon = #{icon},</if>
  142. <if test="remark != null">remark = #{remark},</if>
  143. <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
  144. update_time = sysdate
  145. </set>
  146. where menu_id = #{menuId}
  147. </update>
  148. <insert id="insertMenu" parameterType="SysMenu">
  149. <selectKey keyProperty="menuId" order="BEFORE" resultType="Long">
  150. select seq_sys_menu.nextval as menuId from DUAL
  151. </selectKey>
  152. insert into sys_menu(
  153. <if test="menuId != null and menuId != 0">menu_id,</if>
  154. <if test="parentId != null and parentId != 0">parent_id,</if>
  155. <if test="menuName != null and menuName != ''">menu_name,</if>
  156. <if test="orderNum != null and orderNum != ''">order_num,</if>
  157. <if test="url != null and url != ''">url,</if>
  158. <if test="target != null and target != ''">target,</if>
  159. <if test="menuType != null and menuType != ''">menu_type,</if>
  160. <if test="visible != null">visible,</if>
  161. <if test="isRefresh != null">is_refresh,</if>
  162. <if test="perms !=null and perms != ''">perms,</if>
  163. <if test="icon != null and icon != ''">icon,</if>
  164. <if test="remark != null and remark != ''">remark,</if>
  165. <if test="createBy != null and createBy != ''">create_by,</if>
  166. create_time
  167. )values(
  168. <if test="menuId != null and menuId != 0">#{menuId},</if>
  169. <if test="parentId != null and parentId != 0">#{parentId},</if>
  170. <if test="menuName != null and menuName != ''">#{menuName},</if>
  171. <if test="orderNum != null and orderNum != ''">#{orderNum},</if>
  172. <if test="url != null and url != ''">#{url},</if>
  173. <if test="target != null and target != ''">#{target},</if>
  174. <if test="menuType != null and menuType != ''">#{menuType},</if>
  175. <if test="visible != null">#{visible},</if>
  176. <if test="isRefresh != null">#{isRefresh},</if>
  177. <if test="perms !=null and perms != ''">#{perms},</if>
  178. <if test="icon != null and icon != ''">#{icon},</if>
  179. <if test="remark != null and remark != ''">#{remark},</if>
  180. <if test="createBy != null and createBy != ''">#{createBy},</if>
  181. sysdate
  182. )
  183. </insert>
  184. </mapper>