UserMapper.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  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.UserMapper">
  4. <resultMap id="BaseResultMap" type="com.tzld.piaoquan.wecom.model.po.User">
  5. <id column="id" jdbcType="BIGINT" property="id" />
  6. <result column="corp_id" jdbcType="BIGINT" property="corpId" />
  7. <result column="external_user_id" jdbcType="VARCHAR" property="externalUserId" />
  8. <result column="union_id" jdbcType="VARCHAR" property="unionId" />
  9. <result column="external_user_id_3rd_party" jdbcType="VARCHAR" property="externalUserId3rdParty" />
  10. <result column="type" jdbcType="INTEGER" property="type" />
  11. <result column="name" jdbcType="VARCHAR" property="name" />
  12. <result column="avatar" jdbcType="VARCHAR" property="avatar" />
  13. <result column="gender" jdbcType="INTEGER" property="gender" />
  14. <result column="is_delete" jdbcType="INTEGER" property="isDelete" />
  15. <result column="created_at" jdbcType="BIGINT" property="createdAt" />
  16. <result column="updated_at" jdbcType="BIGINT" property="updatedAt" />
  17. <result column="deleted_at" jdbcType="BIGINT" property="deletedAt" />
  18. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  19. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
  20. </resultMap>
  21. <sql id="Example_Where_Clause">
  22. <where>
  23. <foreach collection="oredCriteria" item="criteria" separator="or">
  24. <if test="criteria.valid">
  25. <trim prefix="(" prefixOverrides="and" suffix=")">
  26. <foreach collection="criteria.criteria" item="criterion">
  27. <choose>
  28. <when test="criterion.noValue">
  29. and ${criterion.condition}
  30. </when>
  31. <when test="criterion.singleValue">
  32. and ${criterion.condition} #{criterion.value}
  33. </when>
  34. <when test="criterion.betweenValue">
  35. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  36. </when>
  37. <when test="criterion.listValue">
  38. and ${criterion.condition}
  39. <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
  40. #{listItem}
  41. </foreach>
  42. </when>
  43. </choose>
  44. </foreach>
  45. </trim>
  46. </if>
  47. </foreach>
  48. </where>
  49. </sql>
  50. <sql id="Update_By_Example_Where_Clause">
  51. <where>
  52. <foreach collection="example.oredCriteria" item="criteria" separator="or">
  53. <if test="criteria.valid">
  54. <trim prefix="(" prefixOverrides="and" suffix=")">
  55. <foreach collection="criteria.criteria" item="criterion">
  56. <choose>
  57. <when test="criterion.noValue">
  58. and ${criterion.condition}
  59. </when>
  60. <when test="criterion.singleValue">
  61. and ${criterion.condition} #{criterion.value}
  62. </when>
  63. <when test="criterion.betweenValue">
  64. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  65. </when>
  66. <when test="criterion.listValue">
  67. and ${criterion.condition}
  68. <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
  69. #{listItem}
  70. </foreach>
  71. </when>
  72. </choose>
  73. </foreach>
  74. </trim>
  75. </if>
  76. </foreach>
  77. </where>
  78. </sql>
  79. <sql id="Base_Column_List">
  80. id, corp_id, external_user_id, union_id, external_user_id_3rd_party, `type`, `name`,
  81. avatar, gender, is_delete, created_at, updated_at, deleted_at, create_time, update_time
  82. </sql>
  83. <select id="selectByExample" parameterType="com.tzld.piaoquan.wecom.model.po.UserExample" resultMap="BaseResultMap">
  84. select
  85. <if test="distinct">
  86. distinct
  87. </if>
  88. <include refid="Base_Column_List" />
  89. from we_com_user
  90. <if test="_parameter != null">
  91. <include refid="Example_Where_Clause" />
  92. </if>
  93. <if test="orderByClause != null">
  94. order by ${orderByClause}
  95. </if>
  96. <if test="page != null">
  97. limit #{page.offset} , #{page.pageSize}
  98. </if>
  99. </select>
  100. <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
  101. select
  102. <include refid="Base_Column_List" />
  103. from we_com_user
  104. where id = #{id,jdbcType=BIGINT}
  105. </select>
  106. <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
  107. delete from we_com_user
  108. where id = #{id,jdbcType=BIGINT}
  109. </delete>
  110. <delete id="deleteByExample" parameterType="com.tzld.piaoquan.wecom.model.po.UserExample">
  111. delete from we_com_user
  112. <if test="_parameter != null">
  113. <include refid="Example_Where_Clause" />
  114. </if>
  115. </delete>
  116. <insert id="insert" parameterType="com.tzld.piaoquan.wecom.model.po.User" useGeneratedKeys="true" keyProperty="id">
  117. insert into we_com_user (id, corp_id, external_user_id,
  118. union_id, external_user_id_3rd_party, `type`,
  119. `name`, avatar, gender,
  120. created_at, updated_at,
  121. deleted_at, create_time, update_time
  122. )
  123. values (#{id,jdbcType=BIGINT}, #{corpId,jdbcType=BIGINT}, #{externalUserId,jdbcType=VARCHAR},
  124. #{unionId,jdbcType=VARCHAR}, #{externalUserId3rdParty,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER},
  125. #{name,jdbcType=VARCHAR}, #{avatar,jdbcType=VARCHAR}, #{gender,jdbcType=INTEGER},
  126. #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT},
  127. #{deletedAt,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}
  128. )
  129. <selectKey resultType="java.lang.Long" order="AFTER" keyProperty="id">
  130. select LAST_INSERT_ID()
  131. </selectKey>
  132. </insert>
  133. <insert id="insertSelective" parameterType="com.tzld.piaoquan.wecom.model.po.User">
  134. insert into we_com_user
  135. <trim prefix="(" suffix=")" suffixOverrides=",">
  136. <if test="id != null">
  137. id,
  138. </if>
  139. <if test="corpId != null">
  140. corp_id,
  141. </if>
  142. <if test="externalUserId != null">
  143. external_user_id,
  144. </if>
  145. <if test="unionId != null">
  146. union_id,
  147. </if>
  148. <if test="externalUserId3rdParty != null">
  149. external_user_id_3rd_party,
  150. </if>
  151. <if test="type != null">
  152. `type`,
  153. </if>
  154. <if test="name != null">
  155. `name`,
  156. </if>
  157. <if test="avatar != null">
  158. avatar,
  159. </if>
  160. <if test="gender != null">
  161. gender,
  162. </if>
  163. <if test="isDelete != null">
  164. is_delete,
  165. </if>
  166. <if test="createdAt != null">
  167. created_at,
  168. </if>
  169. <if test="updatedAt != null">
  170. updated_at,
  171. </if>
  172. <if test="deletedAt != null">
  173. deleted_at,
  174. </if>
  175. <if test="createTime != null">
  176. create_time,
  177. </if>
  178. <if test="updateTime != null">
  179. update_time,
  180. </if>
  181. </trim>
  182. <trim prefix="values (" suffix=")" suffixOverrides=",">
  183. <if test="id != null">
  184. #{id,jdbcType=BIGINT},
  185. </if>
  186. <if test="corpId != null">
  187. #{corpId,jdbcType=BIGINT},
  188. </if>
  189. <if test="externalUserId != null">
  190. #{externalUserId,jdbcType=VARCHAR},
  191. </if>
  192. <if test="unionId != null">
  193. #{unionId,jdbcType=VARCHAR},
  194. </if>
  195. <if test="externalUserId3rdParty != null">
  196. #{externalUserId3rdParty,jdbcType=VARCHAR},
  197. </if>
  198. <if test="type != null">
  199. #{type,jdbcType=INTEGER},
  200. </if>
  201. <if test="name != null">
  202. #{name,jdbcType=VARCHAR},
  203. </if>
  204. <if test="avatar != null">
  205. #{avatar,jdbcType=VARCHAR},
  206. </if>
  207. <if test="gender != null">
  208. #{gender,jdbcType=INTEGER},
  209. </if>
  210. <if test="isDelete != null">
  211. #{isDelete,jdbcType=INTEGER},
  212. </if>
  213. <if test="createdAt != null">
  214. #{createdAt,jdbcType=BIGINT},
  215. </if>
  216. <if test="updatedAt != null">
  217. #{updatedAt,jdbcType=BIGINT},
  218. </if>
  219. <if test="deletedAt != null">
  220. #{deletedAt,jdbcType=BIGINT},
  221. </if>
  222. <if test="createTime != null">
  223. #{createTime,jdbcType=TIMESTAMP},
  224. </if>
  225. <if test="updateTime != null">
  226. #{updateTime,jdbcType=TIMESTAMP},
  227. </if>
  228. </trim>
  229. </insert>
  230. <select id="countByExample" parameterType="com.tzld.piaoquan.wecom.model.po.UserExample" resultType="java.lang.Long">
  231. select count(*) from we_com_user
  232. <if test="_parameter != null">
  233. <include refid="Example_Where_Clause" />
  234. </if>
  235. </select>
  236. <update id="updateByExampleSelective" parameterType="map">
  237. update we_com_user
  238. <set>
  239. <if test="record.id != null">
  240. id = #{record.id,jdbcType=BIGINT},
  241. </if>
  242. <if test="record.corpId != null">
  243. corp_id = #{record.corpId,jdbcType=BIGINT},
  244. </if>
  245. <if test="record.externalUserId != null">
  246. external_user_id = #{record.externalUserId,jdbcType=VARCHAR},
  247. </if>
  248. <if test="record.unionId != null">
  249. union_id = #{record.unionId,jdbcType=VARCHAR},
  250. </if>
  251. <if test="record.externalUserId3rdParty != null">
  252. external_user_id_3rd_party = #{record.externalUserId3rdParty,jdbcType=VARCHAR},
  253. </if>
  254. <if test="record.type != null">
  255. `type` = #{record.type,jdbcType=INTEGER},
  256. </if>
  257. <if test="record.name != null">
  258. `name` = #{record.name,jdbcType=VARCHAR},
  259. </if>
  260. <if test="record.avatar != null">
  261. avatar = #{record.avatar,jdbcType=VARCHAR},
  262. </if>
  263. <if test="record.gender != null">
  264. gender = #{record.gender,jdbcType=INTEGER},
  265. </if>
  266. <if test="record.isDelete != null">
  267. is_delete = #{record.isDelete,jdbcType=INTEGER},
  268. </if>
  269. <if test="record.createdAt != null">
  270. created_at = #{record.createdAt,jdbcType=BIGINT},
  271. </if>
  272. <if test="record.updatedAt != null">
  273. updated_at = #{record.updatedAt,jdbcType=BIGINT},
  274. </if>
  275. <if test="record.deletedAt != null">
  276. deleted_at = #{record.deletedAt,jdbcType=BIGINT},
  277. </if>
  278. <if test="record.createTime != null">
  279. create_time = #{record.createTime,jdbcType=TIMESTAMP},
  280. </if>
  281. <if test="record.updateTime != null">
  282. update_time = #{record.updateTime,jdbcType=TIMESTAMP},
  283. </if>
  284. </set>
  285. <if test="_parameter != null">
  286. <include refid="Update_By_Example_Where_Clause" />
  287. </if>
  288. </update>
  289. <update id="updateByExample" parameterType="map">
  290. update we_com_user
  291. set id = #{record.id,jdbcType=BIGINT},
  292. corp_id = #{record.corpId,jdbcType=BIGINT},
  293. external_user_id = #{record.externalUserId,jdbcType=VARCHAR},
  294. union_id = #{record.unionId,jdbcType=VARCHAR},
  295. external_user_id_3rd_party = #{record.externalUserId3rdParty,jdbcType=VARCHAR},
  296. `type` = #{record.type,jdbcType=INTEGER},
  297. `name` = #{record.name,jdbcType=VARCHAR},
  298. avatar = #{record.avatar,jdbcType=VARCHAR},
  299. gender = #{record.gender,jdbcType=INTEGER},
  300. is_delete = #{record.isDelete,jdbcType=INTEGER},
  301. created_at = #{record.createdAt,jdbcType=BIGINT},
  302. updated_at = #{record.updatedAt,jdbcType=BIGINT},
  303. deleted_at = #{record.deletedAt,jdbcType=BIGINT},
  304. create_time = #{record.createTime,jdbcType=TIMESTAMP},
  305. update_time = #{record.updateTime,jdbcType=TIMESTAMP}
  306. <if test="_parameter != null">
  307. <include refid="Update_By_Example_Where_Clause" />
  308. </if>
  309. </update>
  310. <update id="updateByPrimaryKeySelective" parameterType="com.tzld.piaoquan.wecom.model.po.User">
  311. update we_com_user
  312. <set>
  313. <if test="corpId != null">
  314. corp_id = #{corpId,jdbcType=BIGINT},
  315. </if>
  316. <if test="externalUserId != null">
  317. external_user_id = #{externalUserId,jdbcType=VARCHAR},
  318. </if>
  319. <if test="unionId != null">
  320. union_id = #{unionId,jdbcType=VARCHAR},
  321. </if>
  322. <if test="externalUserId3rdParty != null">
  323. external_user_id_3rd_party = #{externalUserId3rdParty,jdbcType=VARCHAR},
  324. </if>
  325. <if test="type != null">
  326. `type` = #{type,jdbcType=INTEGER},
  327. </if>
  328. <if test="name != null">
  329. `name` = #{name,jdbcType=VARCHAR},
  330. </if>
  331. <if test="avatar != null">
  332. avatar = #{avatar,jdbcType=VARCHAR},
  333. </if>
  334. <if test="gender != null">
  335. gender = #{gender,jdbcType=INTEGER},
  336. </if>
  337. <if test="isDelete != null">
  338. is_delete = #{isDelete,jdbcType=INTEGER},
  339. </if>
  340. <if test="createdAt != null">
  341. created_at = #{createdAt,jdbcType=BIGINT},
  342. </if>
  343. <if test="updatedAt != null">
  344. updated_at = #{updatedAt,jdbcType=BIGINT},
  345. </if>
  346. <if test="deletedAt != null">
  347. deleted_at = #{deletedAt,jdbcType=BIGINT},
  348. </if>
  349. <if test="createTime != null">
  350. create_time = #{createTime,jdbcType=TIMESTAMP},
  351. </if>
  352. <if test="updateTime != null">
  353. update_time = #{updateTime,jdbcType=TIMESTAMP},
  354. </if>
  355. </set>
  356. where id = #{id,jdbcType=BIGINT}
  357. </update>
  358. <update id="updateByPrimaryKey" parameterType="com.tzld.piaoquan.wecom.model.po.User">
  359. update we_com_user
  360. set corp_id = #{corpId,jdbcType=BIGINT},
  361. external_user_id = #{externalUserId,jdbcType=VARCHAR},
  362. union_id = #{unionId,jdbcType=VARCHAR},
  363. external_user_id_3rd_party = #{externalUserId3rdParty,jdbcType=VARCHAR},
  364. `type` = #{type,jdbcType=INTEGER},
  365. `name` = #{name,jdbcType=VARCHAR},
  366. avatar = #{avatar,jdbcType=VARCHAR},
  367. gender = #{gender,jdbcType=INTEGER},
  368. is_delete = #{isDelete,jdbcType=INTEGER},
  369. created_at = #{createdAt,jdbcType=BIGINT},
  370. updated_at = #{updatedAt,jdbcType=BIGINT},
  371. deleted_at = #{deletedAt,jdbcType=BIGINT},
  372. create_time = #{createTime,jdbcType=TIMESTAMP},
  373. update_time = #{updateTime,jdbcType=TIMESTAMP}
  374. where id = #{id,jdbcType=BIGINT}
  375. </update>
  376. <select id="selectIdByExternalUserId3rdParty" parameterType="String" resultType="Long">
  377. select id
  378. from we_com_user
  379. where external_user_id_3rd_party = #{externalUserId3rdParty}
  380. </select>
  381. <select id="selectIdByExternalUserId" parameterType="String" resultType="Long">
  382. select id
  383. from we_com_user
  384. where external_user_id = #{externalUserId}
  385. </select>
  386. <insert id="insertList" parameterType="java.util.List">
  387. insert into we_com_user
  388. (
  389. corp_id,
  390. external_user_id,
  391. union_id,
  392. external_user_id_3rd_party,
  393. `type`,
  394. `name`,
  395. avatar,
  396. gender,
  397. created_at,
  398. updated_at,
  399. deleted_at,
  400. create_time,
  401. update_time
  402. )
  403. values
  404. <foreach collection="list" item="item" separator=",">
  405. (
  406. #{item.corpId,jdbcType=BIGINT}
  407. #{item.externalUserId,jdbcType=VARCHAR},
  408. #{item.unionId,jdbcType=VARCHAR},
  409. #{item.externalUserId3rdParty,jdbcType=VARCHAR},
  410. #{item.type,jdbcType=INTEGER},
  411. #{item.name,jdbcType=VARCHAR},
  412. #{item.avatar,jdbcType=VARCHAR},
  413. #{item.gender,jdbcType=INTEGER},
  414. #{item.createdAt,jdbcType=BIGINT},
  415. #{item.updatedAt,jdbcType=BIGINT},
  416. #{item.deletedAt,jdbcType=BIGINT},
  417. #{item.createTime,jdbcType=TIMESTAMP},
  418. #{item.updateTime,jdbcType=TIMESTAMP}
  419. )
  420. </foreach>
  421. </insert>
  422. </mapper>