KwsUserRoleDao.xml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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.sckw.system.dao.KwsUserRoleDao">
  4. <resultMap id="BaseResultMap" type="com.sckw.system.model.KwsUserRole">
  5. <id column="id" jdbcType="BIGINT" property="id" />
  6. <result column="user_id" jdbcType="BIGINT" property="userId" />
  7. <result column="role_id" jdbcType="BIGINT" property="roleId" />
  8. <result column="remark" jdbcType="VARCHAR" property="remark" />
  9. <result column="status" jdbcType="INTEGER" property="status" />
  10. <result column="create_by" jdbcType="BIGINT" property="createBy" />
  11. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  12. <result column="update_by" jdbcType="BIGINT" property="updateBy" />
  13. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
  14. <result column="del_flag" jdbcType="INTEGER" property="delFlag" />
  15. </resultMap>
  16. <sql id="Base_Column_List">
  17. id, user_id, role_id, remark, status, create_by, create_time, update_by, update_time,
  18. del_flag
  19. </sql>
  20. <select id="selectByKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
  21. select
  22. <include refid="Base_Column_List" />
  23. from kws_user_role
  24. where id = #{id,jdbcType=BIGINT}
  25. </select>
  26. <select id="findAllByUserId" resultType="com.sckw.system.model.KwsUserRole">
  27. select * from kws_user_role where user_id = #{userId} and del_flag = 0 and status = 0
  28. </select>
  29. <select id="findAllByRoleId" resultType="com.sckw.system.model.KwsUserRole">
  30. select * from kws_user_role where role_id = #{roleId} and del_flag = 0 and status = 0
  31. </select>
  32. <select id="findAllByRoleIds" resultType="com.sckw.system.model.KwsUserRole">
  33. select *
  34. from kws_user_role
  35. where del_flag = 0
  36. and status = 0
  37. and role_id in
  38. <foreach collection="list" separator="," open="(" close=")" item="item">
  39. #{item}
  40. </foreach>
  41. </select>
  42. <insert id="insert" parameterType="com.sckw.system.model.KwsUserRole">
  43. insert into kws_user_role
  44. <trim prefix="(" suffix=")" suffixOverrides=",">
  45. <if test="id != null">
  46. id,
  47. </if>
  48. <if test="userId != null">
  49. user_id,
  50. </if>
  51. <if test="roleId != null">
  52. role_id,
  53. </if>
  54. <if test="remark != null">
  55. remark,
  56. </if>
  57. <if test="status != null">
  58. status,
  59. </if>
  60. <if test="createBy != null">
  61. create_by,
  62. </if>
  63. <if test="createTime != null">
  64. create_time,
  65. </if>
  66. <if test="updateBy != null">
  67. update_by,
  68. </if>
  69. <if test="updateTime != null">
  70. update_time,
  71. </if>
  72. <if test="delFlag != null">
  73. del_flag,
  74. </if>
  75. </trim>
  76. <trim prefix="values (" suffix=")" suffixOverrides=",">
  77. <if test="id != null">
  78. #{id,jdbcType=BIGINT},
  79. </if>
  80. <if test="userId != null">
  81. #{userId,jdbcType=BIGINT},
  82. </if>
  83. <if test="roleId != null">
  84. #{roleId,jdbcType=BIGINT},
  85. </if>
  86. <if test="remark != null">
  87. #{remark,jdbcType=VARCHAR},
  88. </if>
  89. <if test="status != null">
  90. #{status,jdbcType=INTEGER},
  91. </if>
  92. <if test="createBy != null">
  93. #{createBy,jdbcType=BIGINT},
  94. </if>
  95. <if test="createTime != null">
  96. #{createTime,jdbcType=TIMESTAMP},
  97. </if>
  98. <if test="updateBy != null">
  99. #{updateBy,jdbcType=BIGINT},
  100. </if>
  101. <if test="updateTime != null">
  102. #{updateTime,jdbcType=TIMESTAMP},
  103. </if>
  104. <if test="delFlag != null">
  105. #{delFlag,jdbcType=INTEGER},
  106. </if>
  107. </trim>
  108. </insert>
  109. <insert id="saveBatch" parameterType="com.sckw.system.model.KwsUserRole">
  110. insert into kws_user_role
  111. <trim prefix="(" suffix=")" suffixOverrides=",">
  112. id,
  113. user_id,
  114. role_id,
  115. remark,
  116. status,
  117. create_by,
  118. create_time,
  119. update_by,
  120. update_time,
  121. del_flag
  122. </trim>
  123. values
  124. <foreach collection="list" item="item" separator=",">
  125. <trim prefix="(" suffix=")" suffixOverrides=",">
  126. #{item.id,jdbcType=BIGINT},
  127. #{item.userId,jdbcType=BIGINT},
  128. #{item.roleId,jdbcType=BIGINT},
  129. #{item.remark,jdbcType=VARCHAR},
  130. #{item.status,jdbcType=INTEGER},
  131. #{item.createBy,jdbcType=BIGINT},
  132. #{item.createTime,jdbcType=TIMESTAMP},
  133. #{item.updateBy,jdbcType=BIGINT},
  134. #{item.updateTime,jdbcType=TIMESTAMP},
  135. #{item.delFlag,jdbcType=INTEGER}
  136. </trim>
  137. </foreach>
  138. </insert>
  139. <update id="update" parameterType="com.sckw.system.model.KwsUserRole">
  140. update kws_user_role
  141. <set>
  142. <if test="userId != null">
  143. user_id = #{userId,jdbcType=BIGINT},
  144. </if>
  145. <if test="roleId != null">
  146. role_id = #{roleId,jdbcType=BIGINT},
  147. </if>
  148. <if test="remark != null">
  149. remark = #{remark,jdbcType=VARCHAR},
  150. </if>
  151. <if test="status != null">
  152. status = #{status,jdbcType=INTEGER},
  153. </if>
  154. <if test="createBy != null">
  155. create_by = #{createBy,jdbcType=BIGINT},
  156. </if>
  157. <if test="createTime != null">
  158. create_time = #{createTime,jdbcType=TIMESTAMP},
  159. </if>
  160. <if test="updateBy != null">
  161. update_by = #{updateBy,jdbcType=BIGINT},
  162. </if>
  163. <if test="updateTime != null">
  164. update_time = #{updateTime,jdbcType=TIMESTAMP},
  165. </if>
  166. <if test="delFlag != null">
  167. del_flag = #{delFlag,jdbcType=INTEGER},
  168. </if>
  169. </set>
  170. where id = #{id,jdbcType=BIGINT}
  171. </update>
  172. </mapper>