RoleMapper.xml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.goafanti.common.dao.RoleMapper">
  4. <resultMap id="BaseResultMap" type="com.goafanti.common.model.Role">
  5. <id column="id" jdbcType="VARCHAR" property="id" />
  6. <result column="role_name" jdbcType="VARCHAR" property="roleName" />
  7. <result column="role_type" jdbcType="INTEGER" property="roleType" />
  8. </resultMap>
  9. <sql id="Base_Column_List">
  10. id, role_name, role_type ,creater,create_time as createTime
  11. </sql>
  12. <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
  13. select
  14. <include refid="Base_Column_List" />
  15. from role
  16. where id = #{id,jdbcType=VARCHAR}
  17. </select>
  18. <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
  19. delete from role
  20. where id = #{id,jdbcType=VARCHAR}
  21. </delete>
  22. <insert id="insert" parameterType="com.goafanti.common.model.Role">
  23. insert into role (id, role_name,creater,create_time)
  24. values (#{id,jdbcType=VARCHAR}, #{roleName,jdbcType=VARCHAR},
  25. #{creater,jdbcType=VARCHAR},#{createTime,jdbcType=VARCHAR})
  26. ON DUPLICATE KEY UPDATE
  27. role_name = values(role_name)
  28. </insert>
  29. <insert id="insertSelective" parameterType="com.goafanti.common.model.Role">
  30. insert into role
  31. <trim prefix="(" suffix=")" suffixOverrides=",">
  32. <if test="id != null">
  33. id,
  34. </if>
  35. <if test="roleName != null">
  36. role_name,
  37. </if>
  38. <if test="roleType != null">
  39. role_type,
  40. </if>
  41. </trim>
  42. <trim prefix="values (" suffix=")" suffixOverrides=",">
  43. <if test="id != null">
  44. #{id,jdbcType=VARCHAR},
  45. </if>
  46. <if test="roleName != null">
  47. #{roleName,jdbcType=VARCHAR},
  48. </if>
  49. <if test="roleType != null">
  50. #{roleType,jdbcType=INTEGER},
  51. </if>
  52. </trim>
  53. </insert>
  54. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.Role">
  55. update role
  56. <set>
  57. <if test="roleName != null">
  58. role_name = #{roleName,jdbcType=VARCHAR},
  59. </if>
  60. <if test="roleType != null">
  61. role_type = #{roleType,jdbcType=INTEGER},
  62. </if>
  63. </set>
  64. where id = #{id,jdbcType=VARCHAR}
  65. </update>
  66. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.Role">
  67. update role
  68. set role_name = #{roleName,jdbcType=VARCHAR},
  69. role_type = #{roleType,jdbcType=INTEGER}
  70. where id = #{id,jdbcType=VARCHAR}
  71. </update>
  72. <insert id="insertBatch" parameterType="com.goafanti.common.model.Role">
  73. insert into role (id, name)
  74. values
  75. <foreach item="item" index="index" collection="list" separator=",">
  76. (#{item.id,jdbcType=VARCHAR}, #{item.name,jdbcType=VARCHAR})
  77. </foreach>
  78. ON DUPLICATE KEY UPDATE
  79. name = values(name)
  80. </insert>
  81. <select id="findRolePermissions" resultType="com.goafanti.permission.bo.RolePermissionBo">
  82. select tr.id as rid, tr.role_name as rname, tr.role_type,tp.id as pid,tp.name as pname,tp.url
  83. from role tr
  84. left join role_permission trp on trp.rid=tr.id
  85. left join permission tp on tp.id=trp.pid
  86. where tr.role_type <![CDATA[ < ]]> 999999
  87. </select>
  88. <select id="findRolePermissionsExceptAreaManager" resultType="com.goafanti.permission.bo.RolePermissionBo">
  89. select tr.id as rid, tr.role_name as rname, tr.role_type,tp.id as pid,tp.name as pname,tp.url
  90. from role tr
  91. left join role_permission trp on trp.rid=tr.id
  92. left join permission tp on tp.id=trp.pid
  93. where tr.role_type <![CDATA[ < ]]> 99999
  94. </select>
  95. <select id="findRoleByUserId" resultType="java.lang.String">
  96. select tr.role_type from role tr
  97. left join user_role tur on tur.rid=tr.id
  98. where tur.uid = #{userId,jdbcType=VARCHAR}
  99. </select>
  100. <delete id="deleteByPrimaryKeys" parameterType="java.lang.String">
  101. delete from role
  102. where id in
  103. <foreach item="item" index="index" collection="list" open="(" separator="," close=")">
  104. #{item,jdbcType=VARCHAR}
  105. </foreach>
  106. </delete>
  107. <!-- ******************************************************************** -->
  108. <select id="selectRoleList" resultType="com.goafanti.permission.bo.RoleBo">
  109. select id,role_name as roleName,role_type as roleType,creater,create_time as createTime
  110. from role
  111. where role_type <![CDATA[ < ]]> 999999
  112. <if test="roleName !=null">
  113. AND role_name=#{roleName,jdbcType=VARCHAR}
  114. </if>
  115. <if test="page_sql != null">
  116. ${page_sql}
  117. </if>
  118. </select>
  119. <select id="selectRoleCount" resultType="java.lang.Integer">
  120. select
  121. count(0)
  122. from role
  123. where
  124. 1=1
  125. <if test="roleName !=null">
  126. AND role_name=#{roleName,jdbcType=VARCHAR}
  127. </if>
  128. </select>
  129. <select id="selectRolePList" resultType="com.goafanti.permission.bo.RolePermissionBo">
  130. select tr.id as rid, tr.role_name as rname, tr.role_type,tp.id as pid,tp.name as pname,tp.url
  131. from role tr
  132. left join role_permission trp on trp.rid=tr.id
  133. left join permission tp on tp.id=trp.pid
  134. where
  135. tr.id=#{id,jdbcType=VARCHAR}
  136. </select>
  137. <select id="selectCountByRoleId" parameterType="java.lang.String" resultType="java.lang.Integer">
  138. select
  139. count(0)
  140. from user_role
  141. where
  142. rid in
  143. <foreach item="item" index="index" collection="list" open="(" separator="," close=")">
  144. #{item,jdbcType=VARCHAR}
  145. </foreach>
  146. </select>
  147. <select id="selectIdByName" parameterType="java.lang.String" resultType="java.lang.String">
  148. select
  149. id
  150. from role
  151. where
  152. role_name=#{roleName,jdbcType=VARCHAR}
  153. </select>
  154. <select id="selectNameById" parameterType="java.lang.String" resultType="java.lang.String">
  155. select
  156. role_name as roleName
  157. from role
  158. where
  159. id=#{id,jdbcType=VARCHAR}
  160. </select>
  161. <select id="selectIdByNamei" parameterType="com.goafanti.common.model.Role" resultType="java.lang.String">
  162. select
  163. id
  164. from role
  165. where
  166. role_name=#{roleName,jdbcType=VARCHAR}
  167. and
  168. id!=#{id,jdbcType=VARCHAR}
  169. </select>
  170. </mapper>