PermissionMapper.xml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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.PermissionMapper">
  4. <resultMap id="BaseResultMap" type="com.goafanti.common.model.Permission">
  5. <id column="id" jdbcType="VARCHAR" property="id" />
  6. <result column="url" jdbcType="VARCHAR" property="url" />
  7. <result column="name" jdbcType="VARCHAR" property="name" />
  8. </resultMap>
  9. <sql id="Base_Column_List">
  10. id, url, name
  11. </sql>
  12. <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
  13. select
  14. <include refid="Base_Column_List" />
  15. from permission
  16. where id = #{id,jdbcType=VARCHAR}
  17. </select>
  18. <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
  19. delete from permission
  20. where id = #{id,jdbcType=VARCHAR}
  21. </delete>
  22. <insert id="insert" parameterType="com.goafanti.common.model.Permission">
  23. insert into permission (id, url, name
  24. )
  25. values (#{id,jdbcType=VARCHAR}, #{url,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}
  26. )
  27. </insert>
  28. <insert id="insertSelective" parameterType="com.goafanti.common.model.Permission">
  29. insert into permission
  30. <trim prefix="(" suffix=")" suffixOverrides=",">
  31. <if test="id != null">
  32. id,
  33. </if>
  34. <if test="url != null">
  35. url,
  36. </if>
  37. <if test="name != null">
  38. name,
  39. </if>
  40. </trim>
  41. <trim prefix="values (" suffix=")" suffixOverrides=",">
  42. <if test="id != null">
  43. #{id,jdbcType=VARCHAR},
  44. </if>
  45. <if test="url != null">
  46. #{url,jdbcType=VARCHAR},
  47. </if>
  48. <if test="name != null">
  49. #{name,jdbcType=VARCHAR},
  50. </if>
  51. </trim>
  52. </insert>
  53. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.Permission">
  54. update permission
  55. <set>
  56. <if test="url != null">
  57. url = #{url,jdbcType=VARCHAR},
  58. </if>
  59. <if test="name != null">
  60. name = #{name,jdbcType=VARCHAR},
  61. </if>
  62. </set>
  63. where id = #{id,jdbcType=VARCHAR}
  64. </update>
  65. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.Permission">
  66. update permission
  67. set url = #{url,jdbcType=VARCHAR},
  68. name = #{name,jdbcType=VARCHAR}
  69. where id = #{id,jdbcType=VARCHAR}
  70. </update>
  71. <select id="findPermissionByUserId" parameterType="java.lang.String" resultType="java.lang.String">
  72. select tp.url
  73. from permission tp
  74. left join role_permission trp on tp.id=trp.pid
  75. left join user_role tur on tur.rid=trp.rid
  76. where tur.uid = #{userId,jdbcType=VARCHAR}
  77. </select>
  78. <select id="findAll" resultMap="BaseResultMap">
  79. select
  80. <include refid="Base_Column_List" />
  81. from permission order by name
  82. </select>
  83. <insert id="insertBatch" parameterType="com.goafanti.common.model.Permission">
  84. insert into permission (id, name, url)
  85. values
  86. <foreach item="item" index="index" collection="list" separator=",">
  87. (#{item.id,jdbcType=VARCHAR}, #{item.name,jdbcType=VARCHAR}, #{item.url,jdbcType=VARCHAR})
  88. </foreach>
  89. ON DUPLICATE KEY UPDATE
  90. name = values(name),
  91. url = values(url)
  92. </insert>
  93. <delete id="deleteByPrimaryKeys" parameterType="java.lang.String">
  94. delete from permission
  95. where id in
  96. <foreach item="item" index="index" collection="list" open="(" separator="," close=")">
  97. #{item,jdbcType=VARCHAR}
  98. </foreach>
  99. </delete>
  100. </mapper>