WeComUserMapper.xml 21 KB

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