StaffWithUserMapper.xml 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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.tzld.piaoquan.wecom.dao.mapper.StaffWithUserMapper">
  4. <resultMap id="BaseResultMap" type="com.tzld.piaoquan.wecom.model.po.StaffWithUser">
  5. <id column="id" jdbcType="BIGINT" property="id" />
  6. <result column="staff_id" jdbcType="BIGINT" property="staffId" />
  7. <result column="user_id" jdbcType="BIGINT" property="userId" />
  8. <result column="is_delete" jdbcType="INTEGER" property="isDelete" />
  9. <result column="delete_time" jdbcType="TIMESTAMP" property="deleteTime" />
  10. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  11. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
  12. </resultMap>
  13. <sql id="Example_Where_Clause">
  14. <where>
  15. <foreach collection="oredCriteria" item="criteria" separator="or">
  16. <if test="criteria.valid">
  17. <trim prefix="(" prefixOverrides="and" suffix=")">
  18. <foreach collection="criteria.criteria" item="criterion">
  19. <choose>
  20. <when test="criterion.noValue">
  21. and ${criterion.condition}
  22. </when>
  23. <when test="criterion.singleValue">
  24. and ${criterion.condition} #{criterion.value}
  25. </when>
  26. <when test="criterion.betweenValue">
  27. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  28. </when>
  29. <when test="criterion.listValue">
  30. and ${criterion.condition}
  31. <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
  32. #{listItem}
  33. </foreach>
  34. </when>
  35. </choose>
  36. </foreach>
  37. </trim>
  38. </if>
  39. </foreach>
  40. </where>
  41. </sql>
  42. <sql id="Update_By_Example_Where_Clause">
  43. <where>
  44. <foreach collection="example.oredCriteria" item="criteria" separator="or">
  45. <if test="criteria.valid">
  46. <trim prefix="(" prefixOverrides="and" suffix=")">
  47. <foreach collection="criteria.criteria" item="criterion">
  48. <choose>
  49. <when test="criterion.noValue">
  50. and ${criterion.condition}
  51. </when>
  52. <when test="criterion.singleValue">
  53. and ${criterion.condition} #{criterion.value}
  54. </when>
  55. <when test="criterion.betweenValue">
  56. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  57. </when>
  58. <when test="criterion.listValue">
  59. and ${criterion.condition}
  60. <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
  61. #{listItem}
  62. </foreach>
  63. </when>
  64. </choose>
  65. </foreach>
  66. </trim>
  67. </if>
  68. </foreach>
  69. </where>
  70. </sql>
  71. <sql id="Base_Column_List">
  72. id, staff_id, user_id, is_delete, delete_time, create_time, update_time
  73. </sql>
  74. <select id="selectByExample" parameterType="com.tzld.piaoquan.wecom.model.po.StaffWithUserExample" resultMap="BaseResultMap">
  75. select
  76. <if test="distinct">
  77. distinct
  78. </if>
  79. <include refid="Base_Column_List" />
  80. from we_com_staff_with_user
  81. <if test="_parameter != null">
  82. <include refid="Example_Where_Clause" />
  83. </if>
  84. <if test="orderByClause != null">
  85. order by ${orderByClause}
  86. </if>
  87. <if test="page != null">
  88. limit #{page.offset} , #{page.pageSize}
  89. </if>
  90. </select>
  91. <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
  92. select
  93. <include refid="Base_Column_List" />
  94. from we_com_staff_with_user
  95. where id = #{id,jdbcType=BIGINT}
  96. </select>
  97. <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
  98. delete from we_com_staff_with_user
  99. where id = #{id,jdbcType=BIGINT}
  100. </delete>
  101. <delete id="deleteByExample" parameterType="com.tzld.piaoquan.wecom.model.po.StaffWithUserExample">
  102. delete from we_com_staff_with_user
  103. <if test="_parameter != null">
  104. <include refid="Example_Where_Clause" />
  105. </if>
  106. </delete>
  107. <insert id="insert" parameterType="com.tzld.piaoquan.wecom.model.po.StaffWithUser">
  108. insert into we_com_staff_with_user (id, staff_id, user_id, delete_time, create_time,
  109. update_time)
  110. values (#{id,jdbcType=BIGINT}, #{staffId,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT},
  111. #{deleteTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP},
  112. #{updateTime,jdbcType=TIMESTAMP})
  113. </insert>
  114. <insert id="insertSelective" parameterType="com.tzld.piaoquan.wecom.model.po.StaffWithUser">
  115. insert into we_com_staff_with_user
  116. <trim prefix="(" suffix=")" suffixOverrides=",">
  117. <if test="id != null">
  118. id,
  119. </if>
  120. <if test="staffId != null">
  121. staff_id,
  122. </if>
  123. <if test="userId != null">
  124. user_id,
  125. </if>
  126. <if test="isDelete != null">
  127. is_delete,
  128. </if>
  129. <if test="deleteTime != null">
  130. delete_time,
  131. </if>
  132. <if test="createTime != null">
  133. create_time,
  134. </if>
  135. <if test="updateTime != null">
  136. update_time,
  137. </if>
  138. </trim>
  139. <trim prefix="values (" suffix=")" suffixOverrides=",">
  140. <if test="id != null">
  141. #{id,jdbcType=BIGINT},
  142. </if>
  143. <if test="staffId != null">
  144. #{staffId,jdbcType=BIGINT},
  145. </if>
  146. <if test="userId != null">
  147. #{userId,jdbcType=BIGINT},
  148. </if>
  149. <if test="isDelete != null">
  150. #{isDelete,jdbcType=INTEGER},
  151. </if>
  152. <if test="deleteTime != null">
  153. #{deleteTime,jdbcType=TIMESTAMP},
  154. </if>
  155. <if test="createTime != null">
  156. #{createTime,jdbcType=TIMESTAMP},
  157. </if>
  158. <if test="updateTime != null">
  159. #{updateTime,jdbcType=TIMESTAMP},
  160. </if>
  161. </trim>
  162. </insert>
  163. <select id="countByExample" parameterType="com.tzld.piaoquan.wecom.model.po.StaffWithUserExample" resultType="java.lang.Long">
  164. select count(*) from we_com_staff_with_user
  165. <if test="_parameter != null">
  166. <include refid="Example_Where_Clause" />
  167. </if>
  168. </select>
  169. <update id="updateByExampleSelective" parameterType="map">
  170. update we_com_staff_with_user
  171. <set>
  172. <if test="record.id != null">
  173. id = #{record.id,jdbcType=BIGINT},
  174. </if>
  175. <if test="record.staffId != null">
  176. staff_id = #{record.staffId,jdbcType=BIGINT},
  177. </if>
  178. <if test="record.userId != null">
  179. user_id = #{record.userId,jdbcType=BIGINT},
  180. </if>
  181. <if test="record.isDelete != null">
  182. is_delete = #{record.isDelete,jdbcType=INTEGER},
  183. </if>
  184. <if test="record.deleteTime != null">
  185. delete_time = #{record.deleteTime,jdbcType=TIMESTAMP},
  186. </if>
  187. <if test="record.createTime != null">
  188. create_time = #{record.createTime,jdbcType=TIMESTAMP},
  189. </if>
  190. <if test="record.updateTime != null">
  191. update_time = #{record.updateTime,jdbcType=TIMESTAMP},
  192. </if>
  193. </set>
  194. <if test="_parameter != null">
  195. <include refid="Update_By_Example_Where_Clause" />
  196. </if>
  197. </update>
  198. <update id="updateByExample" parameterType="map">
  199. update we_com_staff_with_user
  200. set id = #{record.id,jdbcType=BIGINT},
  201. staff_id = #{record.staffId,jdbcType=BIGINT},
  202. user_id = #{record.userId,jdbcType=BIGINT},
  203. is_delete = #{record.isDelete,jdbcType=INTEGER},
  204. delete_time = #{record.deleteTime,jdbcType=TIMESTAMP},
  205. create_time = #{record.createTime,jdbcType=TIMESTAMP},
  206. update_time = #{record.updateTime,jdbcType=TIMESTAMP}
  207. <if test="_parameter != null">
  208. <include refid="Update_By_Example_Where_Clause" />
  209. </if>
  210. </update>
  211. <update id="updateByPrimaryKeySelective" parameterType="com.tzld.piaoquan.wecom.model.po.StaffWithUser">
  212. update we_com_staff_with_user
  213. <set>
  214. <if test="staffId != null">
  215. staff_id = #{staffId,jdbcType=BIGINT},
  216. </if>
  217. <if test="userId != null">
  218. user_id = #{userId,jdbcType=BIGINT},
  219. </if>
  220. <if test="isDelete != null">
  221. is_delete = #{isDelete,jdbcType=INTEGER},
  222. </if>
  223. <if test="deleteTime != null">
  224. delete_time = #{deleteTime,jdbcType=TIMESTAMP},
  225. </if>
  226. <if test="createTime != null">
  227. create_time = #{createTime,jdbcType=TIMESTAMP},
  228. </if>
  229. <if test="updateTime != null">
  230. update_time = #{updateTime,jdbcType=TIMESTAMP},
  231. </if>
  232. </set>
  233. where id = #{id,jdbcType=BIGINT}
  234. </update>
  235. <update id="updateByPrimaryKey" parameterType="com.tzld.piaoquan.wecom.model.po.StaffWithUser">
  236. update we_com_staff_with_user
  237. set staff_id = #{staffId,jdbcType=BIGINT},
  238. user_id = #{userId,jdbcType=BIGINT},
  239. is_delete = #{isDelete,jdbcType=INTEGER},
  240. delete_time = #{deleteTime,jdbcType=TIMESTAMP},
  241. create_time = #{createTime,jdbcType=TIMESTAMP},
  242. update_time = #{updateTime,jdbcType=TIMESTAMP}
  243. where id = #{id,jdbcType=BIGINT}
  244. </update>
  245. <insert id="insertList" parameterType="java.util.List">
  246. insert into we_com_staff_with_user
  247. (
  248. staff_id,
  249. user_id,
  250. is_delete,
  251. delete_time,
  252. create_time,
  253. update_time
  254. )
  255. values
  256. <foreach collection="list" item="item" separator=",">
  257. (
  258. #{item.staffId,jdbcType=BIGINT},
  259. #{item.userId,jdbcType=BIGINT},
  260. #{item.isDelete,jdbcType=INTEGER},
  261. #{item.deleteTime,jdbcType=TIMESTAMP},
  262. #{item.createTime,jdbcType=TIMESTAMP},
  263. #{item.updateTime,jdbcType=TIMESTAMP}
  264. )
  265. </foreach>
  266. </insert>
  267. <select id="selectExternalUserIdByStaffId" parameterType="java.lang.Long" resultType="java.lang.String">
  268. select t2.external_user_id
  269. from we_com_staff_with_user t1
  270. left join we_com_user t2
  271. on t1.user_id = t2.id
  272. where t1.staff_id = #{staffId,jdbcType=BIGINT}
  273. and t2.external_user_id is not null
  274. </select>
  275. </mapper>