RoleMapper.xml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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
  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, role_type
  24. )
  25. values (#{id,jdbcType=VARCHAR}, #{roleName,jdbcType=VARCHAR}, #{roleType,jdbcType=INTEGER}
  26. )
  27. </insert>
  28. <insert id="insertSelective" parameterType="com.goafanti.common.model.Role">
  29. insert into role
  30. <trim prefix="(" suffix=")" suffixOverrides=",">
  31. <if test="id != null">
  32. id,
  33. </if>
  34. <if test="roleName != null">
  35. role_name,
  36. </if>
  37. <if test="roleType != null">
  38. role_type,
  39. </if>
  40. </trim>
  41. <trim prefix="values (" suffix=")" suffixOverrides=",">
  42. <if test="id != null">
  43. #{id,jdbcType=VARCHAR},
  44. </if>
  45. <if test="roleName != null">
  46. #{roleName,jdbcType=VARCHAR},
  47. </if>
  48. <if test="roleType != null">
  49. #{roleType,jdbcType=INTEGER},
  50. </if>
  51. </trim>
  52. </insert>
  53. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.Role">
  54. update role
  55. <set>
  56. <if test="roleName != null">
  57. role_name = #{roleName,jdbcType=VARCHAR},
  58. </if>
  59. <if test="roleType != null">
  60. role_type = #{roleType,jdbcType=INTEGER},
  61. </if>
  62. </set>
  63. where id = #{id,jdbcType=VARCHAR}
  64. </update>
  65. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.Role">
  66. update role
  67. set role_name = #{roleName,jdbcType=VARCHAR},
  68. role_type = #{roleType,jdbcType=INTEGER}
  69. where id = #{id,jdbcType=VARCHAR}
  70. </update>
  71. <insert id="insertBatch" parameterType="com.goafanti.common.model.Role">
  72. insert into role (id, name)
  73. values
  74. <foreach item="item" index="index" collection="list" separator=",">
  75. (#{item.id,jdbcType=VARCHAR}, #{item.name,jdbcType=VARCHAR})
  76. </foreach>
  77. ON DUPLICATE KEY UPDATE
  78. name = values(name)
  79. </insert>
  80. <select id="findRolePermissions" resultType="com.goafanti.permission.bo.RolePermissionBo">
  81. select tr.id as rid, tr.role_name as rname, tr.role_type,tp.id as pid,tp.name as pname,tp.url
  82. from role tr
  83. left join role_permission trp on trp.rid=tr.id
  84. left join permission tp on tp.id=trp.pid
  85. where tr.role_type <![CDATA[ < ]]> 999999
  86. </select>
  87. <select id="findRoleByUserId" resultType="java.lang.String">
  88. select tr.role_type from role tr
  89. left join user_role tur on tur.rid=tr.id
  90. where tur.uid = #{userId,jdbcType=VARCHAR}
  91. </select>
  92. <delete id="deleteByPrimaryKeys" parameterType="java.lang.String">
  93. delete from role
  94. where id in
  95. <foreach item="item" index="index" collection="list" open="(" separator="," close=")">
  96. #{item,jdbcType=VARCHAR}
  97. </foreach>
  98. </delete>
  99. </mapper>