SendMessageMapper.xml 12 KB

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