Menu.xml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <!-- namespace必须指向DAO接口 -->
  5. <mapper namespace="com.jpsoft.picc.modules.sys.dao.MenuDAO">
  6. <resultMap id="MenuMap" type="com.jpsoft.picc.modules.sys.entity.Menu">
  7. <id property="id" column="id_"/>
  8. <result property="menuName" column="menu_name"/>
  9. <result property="parentId" column="parent_id"/>
  10. <result property="parentName" column="parent_name"/>
  11. <result property="sortNo" column="sort_no"/>
  12. <result property="menuUrl" column="menu_url"/>
  13. <result property="icon" column="icon_"/>
  14. <result property="menuType" column="menu_type"/>
  15. <result property="createTime" column="create_time"/>
  16. <result property="createBy" column="create_by"/>
  17. <result property="updateTime" column="update_time"/>
  18. <result property="updateBy" column="update_by"/>
  19. <result property="delFlag" column="del_flag"/>
  20. </resultMap>
  21. <insert id="insert" parameterType="com.jpsoft.picc.modules.sys.entity.Menu">
  22. <!--
  23. <selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
  24. select sys_guid() from dual
  25. </selectKey>
  26. -->
  27. <![CDATA[
  28. insert into sys_menu
  29. (id_,menu_name,parent_id,sort_no,menu_url,menu_type,create_time,create_by,update_time,update_by,del_flag,icon_)
  30. values
  31. (
  32. #{id,jdbcType=VARCHAR}
  33. ,#{menuName,jdbcType=VARCHAR}
  34. ,#{parentId,jdbcType=VARCHAR}
  35. ,#{sortNo,jdbcType= NUMERIC }
  36. ,#{menuUrl,jdbcType=VARCHAR}
  37. ,#{menuType,jdbcType=VARCHAR}
  38. ,#{createTime,jdbcType= TIMESTAMP }
  39. ,#{createBy,jdbcType=VARCHAR}
  40. ,#{updateTime,jdbcType= TIMESTAMP }
  41. ,#{updateBy,jdbcType=VARCHAR}
  42. ,#{delFlag,jdbcType= NUMERIC }
  43. ,#{icon,jdbcType=VARCHAR}
  44. )
  45. ]]>
  46. </insert>
  47. <delete id="delete" parameterType="string">
  48. delete from sys_menu where id_=#{id,jdbcType=VARCHAR}
  49. </delete>
  50. <update id="update" parameterType="com.jpsoft.picc.modules.sys.entity.Menu">
  51. update sys_menu
  52. <set>
  53. <if test="menuName!=null">
  54. menu_name=#{menuName,jdbcType=VARCHAR},
  55. </if>
  56. <if test="parentId!=null">
  57. parent_id=#{parentId,jdbcType=VARCHAR},
  58. </if>
  59. <if test="sortNo!=null">
  60. sort_no=#{sortNo,jdbcType= NUMERIC },
  61. </if>
  62. <if test="menuUrl!=null">
  63. menu_url=#{menuUrl,jdbcType=VARCHAR},
  64. </if>
  65. <if test="menuType!=null">
  66. menu_type=#{menuType,jdbcType=VARCHAR},
  67. </if>
  68. <if test="createTime!=null">
  69. create_time=#{createTime,jdbcType= TIMESTAMP },
  70. </if>
  71. <if test="createBy!=null">
  72. create_by=#{createBy,jdbcType=VARCHAR},
  73. </if>
  74. <if test="updateTime!=null">
  75. update_time=#{updateTime,jdbcType= TIMESTAMP },
  76. </if>
  77. <if test="updateBy!=null">
  78. update_by=#{updateBy,jdbcType=VARCHAR},
  79. </if>
  80. <if test="delFlag!=null">
  81. del_flag=#{delFlag,jdbcType= NUMERIC },
  82. </if>
  83. <if test="icon!=null">
  84. icon_=#{icon,jdbcType=VARCHAR},
  85. </if>
  86. </set>
  87. where id_=#{id}
  88. </update>
  89. <select id="get" parameterType="string" resultMap="MenuMap">
  90. select a.*,b.menu_name as parent_name
  91. from sys_menu a left join sys_menu b on a.parent_id = b.id_
  92. where a.id_=#{0}
  93. </select>
  94. <select id="exist" parameterType="string" resultType="int">
  95. select count(*) from sys_menu where id_=#{0}
  96. </select>
  97. <select id="list" resultMap="MenuMap">
  98. select * from sys_menu
  99. </select>
  100. <select id="search" parameterType="hashmap" resultMap="MenuMap">
  101. <![CDATA[
  102. select a.*,b.menu_name as parent_name
  103. from sys_menu a left join sys_menu b on a.parent_id = b.id_
  104. ]]>
  105. where a.del_flag=0
  106. <if test="searchParams.menuName != null">
  107. and a.menu_name like #{searchParams.menuName}
  108. </if>
  109. <if test="searchParams.menuType != null">
  110. and a.menu_type = #{searchParams.menuType}
  111. </if>
  112. <if test="searchParams.parentId != null">
  113. and a.parent_id = #{searchParams.parentId}
  114. </if>
  115. <if test="searchParams.excludeId != null">
  116. <![CDATA[
  117. and a.id_ <> #{searchParams.excludeId}
  118. ]]>
  119. </if>
  120. <foreach item="sort" collection="sortList" open="order by" separator=",">
  121. ${sort.name} ${sort.order}
  122. </foreach>
  123. </select>
  124. <select id="findAllocMenu" parameterType="string" resultMap="MenuMap">
  125. select * from sys_menu m,sys_role_menu rm,sys_user_role ur
  126. where ur.user_id=#{userId}
  127. and ur.role_id = rm.role_id
  128. and rm.menu_id = m.id_
  129. and m.menu_type = 2
  130. and m.del_flag=0
  131. <if test="parentId==null">
  132. and m.parent_id is null
  133. </if>
  134. <if test="parentId!=null">
  135. and m.parent_id = #{parentId}
  136. </if>
  137. order by m.sort_no asc
  138. </select>
  139. </mapper>