SendMessageMapper.xml 13 KB

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