KwsUserRoleDao.xml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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}
  28. </select>
  29. <insert id="insert" parameterType="com.sckw.system.model.KwsUserRole">
  30. insert into kws_user_role
  31. <trim prefix="(" suffix=")" suffixOverrides=",">
  32. <if test="id != null">
  33. id,
  34. </if>
  35. <if test="userId != null">
  36. user_id,
  37. </if>
  38. <if test="roleId != null">
  39. role_id,
  40. </if>
  41. <if test="remark != null">
  42. remark,
  43. </if>
  44. <if test="status != null">
  45. status,
  46. </if>
  47. <if test="createBy != null">
  48. create_by,
  49. </if>
  50. <if test="createTime != null">
  51. create_time,
  52. </if>
  53. <if test="updateBy != null">
  54. update_by,
  55. </if>
  56. <if test="updateTime != null">
  57. update_time,
  58. </if>
  59. <if test="delFlag != null">
  60. del_flag,
  61. </if>
  62. </trim>
  63. <trim prefix="values (" suffix=")" suffixOverrides=",">
  64. <if test="id != null">
  65. #{id,jdbcType=BIGINT},
  66. </if>
  67. <if test="userId != null">
  68. #{userId,jdbcType=BIGINT},
  69. </if>
  70. <if test="roleId != null">
  71. #{roleId,jdbcType=BIGINT},
  72. </if>
  73. <if test="remark != null">
  74. #{remark,jdbcType=VARCHAR},
  75. </if>
  76. <if test="status != null">
  77. #{status,jdbcType=INTEGER},
  78. </if>
  79. <if test="createBy != null">
  80. #{createBy,jdbcType=BIGINT},
  81. </if>
  82. <if test="createTime != null">
  83. #{createTime,jdbcType=TIMESTAMP},
  84. </if>
  85. <if test="updateBy != null">
  86. #{updateBy,jdbcType=BIGINT},
  87. </if>
  88. <if test="updateTime != null">
  89. #{updateTime,jdbcType=TIMESTAMP},
  90. </if>
  91. <if test="delFlag != null">
  92. #{delFlag,jdbcType=INTEGER},
  93. </if>
  94. </trim>
  95. </insert>
  96. <insert id="saveBatch" parameterType="com.sckw.system.model.KwsUserRole">
  97. insert into kws_user_role
  98. <trim prefix="(" suffix=")" suffixOverrides=",">
  99. id,
  100. user_id,
  101. role_id,
  102. remark,
  103. status,
  104. create_by,
  105. create_time,
  106. update_by,
  107. update_time,
  108. del_flag
  109. </trim>
  110. values
  111. <foreach collection="list" item="item" separator=",">
  112. <trim prefix="(" suffix=")" suffixOverrides=",">
  113. #{item.id,jdbcType=BIGINT},
  114. #{item.userId,jdbcType=BIGINT},
  115. #{item.roleId,jdbcType=BIGINT},
  116. #{item.remark,jdbcType=VARCHAR},
  117. #{item.status,jdbcType=INTEGER},
  118. #{item.createBy,jdbcType=BIGINT},
  119. #{item.createTime,jdbcType=TIMESTAMP},
  120. #{item.updateBy,jdbcType=BIGINT},
  121. #{item.updateTime,jdbcType=TIMESTAMP},
  122. #{item.delFlag,jdbcType=INTEGER}
  123. </trim>
  124. </foreach>
  125. </insert>
  126. <update id="update" parameterType="com.sckw.system.model.KwsUserRole">
  127. update kws_user_role
  128. <set>
  129. <if test="userId != null">
  130. user_id = #{userId,jdbcType=BIGINT},
  131. </if>
  132. <if test="roleId != null">
  133. role_id = #{roleId,jdbcType=BIGINT},
  134. </if>
  135. <if test="remark != null">
  136. remark = #{remark,jdbcType=VARCHAR},
  137. </if>
  138. <if test="status != null">
  139. status = #{status,jdbcType=INTEGER},
  140. </if>
  141. <if test="createBy != null">
  142. create_by = #{createBy,jdbcType=BIGINT},
  143. </if>
  144. <if test="createTime != null">
  145. create_time = #{createTime,jdbcType=TIMESTAMP},
  146. </if>
  147. <if test="updateBy != null">
  148. update_by = #{updateBy,jdbcType=BIGINT},
  149. </if>
  150. <if test="updateTime != null">
  151. update_time = #{updateTime,jdbcType=TIMESTAMP},
  152. </if>
  153. <if test="delFlag != null">
  154. del_flag = #{delFlag,jdbcType=INTEGER},
  155. </if>
  156. </set>
  157. where id = #{id,jdbcType=BIGINT}
  158. </update>
  159. </mapper>