MessageFromSystemMapper.xml 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714
  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.goafanti.common.dao.MessageFromSystemMapper">
  4. <resultMap id="BaseResultMap" type="com.goafanti.common.model.MessageFromSystem">
  5. <!--
  6. WARNING - @mbg.generated
  7. This element is automatically generated by MyBatis Generator, do not modify.
  8. This element was generated on Mon Dec 25 18:55:04 CST 2017.
  9. -->
  10. <id column="id" jdbcType="VARCHAR" property="id" />
  11. <result column="creater" jdbcType="VARCHAR" property="creater" />
  12. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  13. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
  14. <result column="producer_id" jdbcType="VARCHAR" property="producerId" />
  15. <result column="consumer_type" jdbcType="INTEGER" property="consumerType" />
  16. <result column="title" jdbcType="VARCHAR" property="title" />
  17. <result column="body" jdbcType="VARCHAR" property="body" />
  18. <result column="subject" jdbcType="INTEGER" property="subject" />
  19. <result column="resource_id" jdbcType="VARCHAR" property="resourceId" />
  20. <result column="resource_type" jdbcType="INTEGER" property="resourceType" />
  21. <result column="delete_sign" jdbcType="BIT" property="deleteSign" />
  22. <result column="is_draft" jdbcType="INTEGER" property="isDraft" />
  23. </resultMap>
  24. <sql id="Example_Where_Clause">
  25. <!--
  26. WARNING - @mbg.generated
  27. This element is automatically generated by MyBatis Generator, do not modify.
  28. This element was generated on Mon Dec 25 18:55:04 CST 2017.
  29. -->
  30. <where>
  31. <foreach collection="oredCriteria" item="criteria" separator="or">
  32. <if test="criteria.valid">
  33. <trim prefix="(" prefixOverrides="and" suffix=")">
  34. <foreach collection="criteria.criteria" item="criterion">
  35. <choose>
  36. <when test="criterion.noValue">
  37. and ${criterion.condition}
  38. </when>
  39. <when test="criterion.singleValue">
  40. and ${criterion.condition} #{criterion.value}
  41. </when>
  42. <when test="criterion.betweenValue">
  43. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  44. </when>
  45. <when test="criterion.listValue">
  46. and ${criterion.condition}
  47. <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
  48. #{listItem}
  49. </foreach>
  50. </when>
  51. </choose>
  52. </foreach>
  53. </trim>
  54. </if>
  55. </foreach>
  56. </where>
  57. </sql>
  58. <sql id="Update_By_Example_Where_Clause">
  59. <!--
  60. WARNING - @mbg.generated
  61. This element is automatically generated by MyBatis Generator, do not modify.
  62. This element was generated on Mon Dec 25 18:55:04 CST 2017.
  63. -->
  64. <where>
  65. <foreach collection="example.oredCriteria" item="criteria" separator="or">
  66. <if test="criteria.valid">
  67. <trim prefix="(" prefixOverrides="and" suffix=")">
  68. <foreach collection="criteria.criteria" item="criterion">
  69. <choose>
  70. <when test="criterion.noValue">
  71. and ${criterion.condition}
  72. </when>
  73. <when test="criterion.singleValue">
  74. and ${criterion.condition} #{criterion.value}
  75. </when>
  76. <when test="criterion.betweenValue">
  77. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  78. </when>
  79. <when test="criterion.listValue">
  80. and ${criterion.condition}
  81. <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
  82. #{listItem}
  83. </foreach>
  84. </when>
  85. </choose>
  86. </foreach>
  87. </trim>
  88. </if>
  89. </foreach>
  90. </where>
  91. </sql>
  92. <sql id="Base_Column_List">
  93. <!--
  94. WARNING - @mbg.generated
  95. This element is automatically generated by MyBatis Generator, do not modify.
  96. This element was generated on Mon Dec 25 18:55:04 CST 2017.
  97. -->
  98. id, creater, create_time, update_time, producer_id, consumer_type, title, body, subject,
  99. resource_id, resource_type, delete_sign, is_draft
  100. </sql>
  101. <select id="selectByExample" parameterType="com.goafanti.common.model.MessageFromSystemExample" resultMap="BaseResultMap">
  102. <!--
  103. WARNING - @mbg.generated
  104. This element is automatically generated by MyBatis Generator, do not modify.
  105. This element was generated on Mon Dec 25 18:55:04 CST 2017.
  106. -->
  107. select
  108. <if test="distinct">
  109. distinct
  110. </if>
  111. <include refid="Base_Column_List" />
  112. from message_from_system
  113. <if test="_parameter != null">
  114. <include refid="Example_Where_Clause" />
  115. </if>
  116. <if test="orderByClause != null">
  117. order by ${orderByClause}
  118. </if>
  119. </select>
  120. <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
  121. <!--
  122. WARNING - @mbg.generated
  123. This element is automatically generated by MyBatis Generator, do not modify.
  124. This element was generated on Mon Dec 25 18:55:04 CST 2017.
  125. -->
  126. select
  127. <include refid="Base_Column_List" />
  128. from message_from_system
  129. where id = #{id,jdbcType=VARCHAR}
  130. </select>
  131. <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
  132. <!--
  133. WARNING - @mbg.generated
  134. This element is automatically generated by MyBatis Generator, do not modify.
  135. This element was generated on Mon Dec 25 18:55:04 CST 2017.
  136. -->
  137. delete from message_from_system
  138. where id = #{id,jdbcType=VARCHAR}
  139. </delete>
  140. <delete id="deleteByExample" parameterType="com.goafanti.common.model.MessageFromSystemExample">
  141. <!--
  142. WARNING - @mbg.generated
  143. This element is automatically generated by MyBatis Generator, do not modify.
  144. This element was generated on Mon Dec 25 18:55:04 CST 2017.
  145. -->
  146. delete from message_from_system
  147. <if test="_parameter != null">
  148. <include refid="Example_Where_Clause" />
  149. </if>
  150. </delete>
  151. <insert id="insert" parameterType="com.goafanti.common.model.MessageFromSystem">
  152. <!--
  153. WARNING - @mbg.generated
  154. This element is automatically generated by MyBatis Generator, do not modify.
  155. This element was generated on Mon Dec 25 18:55:04 CST 2017.
  156. -->
  157. insert into message_from_system (id, creater, create_time,
  158. update_time, producer_id, consumer_type,
  159. title, body, subject,
  160. resource_id, resource_type, delete_sign,
  161. is_draft)
  162. values (#{id,jdbcType=VARCHAR}, #{creater,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
  163. #{updateTime,jdbcType=TIMESTAMP}, #{producerId,jdbcType=VARCHAR}, #{consumerType,jdbcType=INTEGER},
  164. #{title,jdbcType=VARCHAR}, #{body,jdbcType=VARCHAR}, #{subject,jdbcType=INTEGER},
  165. #{resourceId,jdbcType=VARCHAR}, #{resourceType,jdbcType=INTEGER}, #{deleteSign,jdbcType=BIT},
  166. #{isDraft,jdbcType=INTEGER})
  167. </insert>
  168. <insert id="insertSelective" parameterType="com.goafanti.common.model.MessageFromSystem">
  169. <!--
  170. WARNING - @mbg.generated
  171. This element is automatically generated by MyBatis Generator, do not modify.
  172. This element was generated on Mon Dec 25 18:55:04 CST 2017.
  173. -->
  174. insert into message_from_system
  175. <trim prefix="(" suffix=")" suffixOverrides=",">
  176. <if test="id != null">
  177. id,
  178. </if>
  179. <if test="creater != null">
  180. creater,
  181. </if>
  182. <if test="createTime != null">
  183. create_time,
  184. </if>
  185. <if test="updateTime != null">
  186. update_time,
  187. </if>
  188. <if test="producerId != null">
  189. producer_id,
  190. </if>
  191. <if test="consumerType != null">
  192. consumer_type,
  193. </if>
  194. <if test="title != null">
  195. title,
  196. </if>
  197. <if test="body != null">
  198. body,
  199. </if>
  200. <if test="subject != null">
  201. subject,
  202. </if>
  203. <if test="resourceId != null">
  204. resource_id,
  205. </if>
  206. <if test="resourceType != null">
  207. resource_type,
  208. </if>
  209. <if test="deleteSign != null">
  210. delete_sign,
  211. </if>
  212. <if test="isDraft != null">
  213. is_draft,
  214. </if>
  215. </trim>
  216. <trim prefix="values (" suffix=")" suffixOverrides=",">
  217. <if test="id != null">
  218. #{id,jdbcType=VARCHAR},
  219. </if>
  220. <if test="creater != null">
  221. #{creater,jdbcType=VARCHAR},
  222. </if>
  223. <if test="createTime != null">
  224. #{createTime,jdbcType=TIMESTAMP},
  225. </if>
  226. <if test="updateTime != null">
  227. #{updateTime,jdbcType=TIMESTAMP},
  228. </if>
  229. <if test="producerId != null">
  230. #{producerId,jdbcType=VARCHAR},
  231. </if>
  232. <if test="consumerType != null">
  233. #{consumerType,jdbcType=INTEGER},
  234. </if>
  235. <if test="title != null">
  236. #{title,jdbcType=VARCHAR},
  237. </if>
  238. <if test="body != null">
  239. #{body,jdbcType=VARCHAR},
  240. </if>
  241. <if test="subject != null">
  242. #{subject,jdbcType=INTEGER},
  243. </if>
  244. <if test="resourceId != null">
  245. #{resourceId,jdbcType=VARCHAR},
  246. </if>
  247. <if test="resourceType != null">
  248. #{resourceType,jdbcType=INTEGER},
  249. </if>
  250. <if test="deleteSign != null">
  251. #{deleteSign,jdbcType=BIT},
  252. </if>
  253. <if test="isDraft != null">
  254. #{isDraft,jdbcType=INTEGER},
  255. </if>
  256. </trim>
  257. </insert>
  258. <select id="countByExample" parameterType="com.goafanti.common.model.MessageFromSystemExample" resultType="java.lang.Long">
  259. <!--
  260. WARNING - @mbg.generated
  261. This element is automatically generated by MyBatis Generator, do not modify.
  262. This element was generated on Mon Dec 25 18:55:04 CST 2017.
  263. -->
  264. select count(*) from message_from_system
  265. <if test="_parameter != null">
  266. <include refid="Example_Where_Clause" />
  267. </if>
  268. </select>
  269. <update id="updateByExampleSelective" parameterType="map">
  270. <!--
  271. WARNING - @mbg.generated
  272. This element is automatically generated by MyBatis Generator, do not modify.
  273. This element was generated on Mon Dec 25 18:55:04 CST 2017.
  274. -->
  275. update message_from_system
  276. <set>
  277. <if test="record.id != null">
  278. id = #{record.id,jdbcType=VARCHAR},
  279. </if>
  280. <if test="record.creater != null">
  281. creater = #{record.creater,jdbcType=VARCHAR},
  282. </if>
  283. <if test="record.createTime != null">
  284. create_time = #{record.createTime,jdbcType=TIMESTAMP},
  285. </if>
  286. <if test="record.updateTime != null">
  287. update_time = #{record.updateTime,jdbcType=TIMESTAMP},
  288. </if>
  289. <if test="record.producerId != null">
  290. producer_id = #{record.producerId,jdbcType=VARCHAR},
  291. </if>
  292. <if test="record.consumerType != null">
  293. consumer_type = #{record.consumerType,jdbcType=INTEGER},
  294. </if>
  295. <if test="record.title != null">
  296. title = #{record.title,jdbcType=VARCHAR},
  297. </if>
  298. <if test="record.body != null">
  299. body = #{record.body,jdbcType=VARCHAR},
  300. </if>
  301. <if test="record.subject != null">
  302. subject = #{record.subject,jdbcType=INTEGER},
  303. </if>
  304. <if test="record.resourceId != null">
  305. resource_id = #{record.resourceId,jdbcType=VARCHAR},
  306. </if>
  307. <if test="record.resourceType != null">
  308. resource_type = #{record.resourceType,jdbcType=INTEGER},
  309. </if>
  310. <if test="record.deleteSign != null">
  311. delete_sign = #{record.deleteSign,jdbcType=BIT},
  312. </if>
  313. <if test="record.isDraft != null">
  314. is_draft = #{record.isDraft,jdbcType=INTEGER},
  315. </if>
  316. </set>
  317. <if test="_parameter != null">
  318. <include refid="Update_By_Example_Where_Clause" />
  319. </if>
  320. </update>
  321. <update id="updateByExample" parameterType="map">
  322. <!--
  323. WARNING - @mbg.generated
  324. This element is automatically generated by MyBatis Generator, do not modify.
  325. This element was generated on Mon Dec 25 18:55:04 CST 2017.
  326. -->
  327. update message_from_system
  328. set id = #{record.id,jdbcType=VARCHAR},
  329. creater = #{record.creater,jdbcType=VARCHAR},
  330. create_time = #{record.createTime,jdbcType=TIMESTAMP},
  331. update_time = #{record.updateTime,jdbcType=TIMESTAMP},
  332. producer_id = #{record.producerId,jdbcType=VARCHAR},
  333. consumer_type = #{record.consumerType,jdbcType=INTEGER},
  334. title = #{record.title,jdbcType=VARCHAR},
  335. body = #{record.body,jdbcType=VARCHAR},
  336. subject = #{record.subject,jdbcType=INTEGER},
  337. resource_id = #{record.resourceId,jdbcType=VARCHAR},
  338. resource_type = #{record.resourceType,jdbcType=INTEGER},
  339. delete_sign = #{record.deleteSign,jdbcType=BIT},
  340. is_draft = #{record.isDraft,jdbcType=INTEGER}
  341. <if test="_parameter != null">
  342. <include refid="Update_By_Example_Where_Clause" />
  343. </if>
  344. </update>
  345. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.MessageFromSystem">
  346. <!--
  347. WARNING - @mbg.generated
  348. This element is automatically generated by MyBatis Generator, do not modify.
  349. This element was generated on Mon Dec 25 18:55:04 CST 2017.
  350. -->
  351. update message_from_system
  352. <set>
  353. <if test="creater != null">
  354. creater = #{creater,jdbcType=VARCHAR},
  355. </if>
  356. <if test="createTime != null">
  357. create_time = #{createTime,jdbcType=TIMESTAMP},
  358. </if>
  359. <if test="updateTime != null">
  360. update_time = #{updateTime,jdbcType=TIMESTAMP},
  361. </if>
  362. <if test="producerId != null">
  363. producer_id = #{producerId,jdbcType=VARCHAR},
  364. </if>
  365. <if test="consumerType != null">
  366. consumer_type = #{consumerType,jdbcType=INTEGER},
  367. </if>
  368. <if test="title != null">
  369. title = #{title,jdbcType=VARCHAR},
  370. </if>
  371. <if test="body != null">
  372. body = #{body,jdbcType=VARCHAR},
  373. </if>
  374. <if test="subject != null">
  375. subject = #{subject,jdbcType=INTEGER},
  376. </if>
  377. <if test="resourceId != null">
  378. resource_id = #{resourceId,jdbcType=VARCHAR},
  379. </if>
  380. <if test="resourceType != null">
  381. resource_type = #{resourceType,jdbcType=INTEGER},
  382. </if>
  383. <if test="deleteSign != null">
  384. delete_sign = #{deleteSign,jdbcType=BIT},
  385. </if>
  386. <if test="isDraft != null">
  387. is_draft = #{isDraft,jdbcType=INTEGER},
  388. </if>
  389. </set>
  390. where id = #{id,jdbcType=VARCHAR}
  391. </update>
  392. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.MessageFromSystem">
  393. <!--
  394. WARNING - @mbg.generated
  395. This element is automatically generated by MyBatis Generator, do not modify.
  396. This element was generated on Mon Dec 25 18:55:04 CST 2017.
  397. -->
  398. update message_from_system
  399. set creater = #{creater,jdbcType=VARCHAR},
  400. create_time = #{createTime,jdbcType=TIMESTAMP},
  401. update_time = #{updateTime,jdbcType=TIMESTAMP},
  402. producer_id = #{producerId,jdbcType=VARCHAR},
  403. consumer_type = #{consumerType,jdbcType=INTEGER},
  404. title = #{title,jdbcType=VARCHAR},
  405. body = #{body,jdbcType=VARCHAR},
  406. subject = #{subject,jdbcType=INTEGER},
  407. resource_id = #{resourceId,jdbcType=VARCHAR},
  408. resource_type = #{resourceType,jdbcType=INTEGER},
  409. delete_sign = #{deleteSign,jdbcType=BIT},
  410. is_draft = #{isDraft,jdbcType=INTEGER}
  411. where id = #{id,jdbcType=VARCHAR}
  412. </update>
  413. <insert id="insertBatchMessage" parameterType="com.goafanti.common.model.MessageFromSystem">
  414. insert into message_from_system (id,creater,producer_id,
  415. consumer_type,title,body,subject,resource_id,resource_type,delete_sign,is_draft)
  416. values
  417. <foreach collection="list" index="index" item="item" separator=",">
  418. (
  419. #{item.id,jdbcType=VARCHAR},
  420. #{item.creater,jdbcType=VARCHAR},
  421. #{item.producerId,jdbcType=VARCHAR},
  422. #{item.consumerType,jdbcType=VARCHAR},
  423. #{item.title,jdbcType=VARCHAR},
  424. #{item.body,jdbcType=VARCHAR},
  425. #{item.subject,jdbcType=VARCHAR},
  426. #{item.resourceId,jdbcType=VARCHAR},
  427. #{item.resourceType,jdbcType=VARCHAR},
  428. #{item.deleteSign,jdbcType=VARCHAR},
  429. #{item.isDraft,jdbcType=VARCHAR}
  430. )
  431. </foreach>
  432. </insert>
  433. <insert id="insertBatchProducer" parameterType="com.goafanti.common.model.MessageProducer">
  434. insert into message_producer (id,consumer_id,message_id)
  435. values
  436. <foreach collection="list" index="index" item="item" separator=",">
  437. (
  438. #{item.id,jdbcType=VARCHAR},#{item.consumerId,jdbcType=VARCHAR},#{item.messageId,jdbcType=VARCHAR}
  439. )
  440. </foreach>
  441. </insert>
  442. <insert id="insertBatchConsumer" parameterType="com.goafanti.common.model.MessageConsumer">
  443. insert into message_consumer (id,consumer_id,message_id)
  444. values
  445. <foreach collection="list" index="index" item="item" separator=",">
  446. (
  447. #{item.id,jdbcType=VARCHAR},#{item.consumerId,jdbcType=VARCHAR},#{item.messageId,jdbcType=VARCHAR}
  448. )
  449. </foreach>
  450. </insert>
  451. <select id="selectSyncMessage" parameterType="java.lang.String" resultType="com.goafanti.message.bo.MessageBo">
  452. <!-- 登陆时同步 -->
  453. select
  454. x.id,
  455. x.message_id as messageId
  456. from
  457. message_producer x left join message_from_system y on
  458. x.message_id = y.id
  459. where x.id
  460. not in(
  461. select
  462. a.id
  463. from
  464. message_producer a inner join message_consumer b on
  465. (
  466. a.message_id = b.message_id
  467. and a.consumer_id = b.consumer_id
  468. )
  469. )
  470. and x.consumer_id = #{uid,jdbcType=VARCHAR}
  471. and y.is_draft = 0 <!-- 非草稿 -->
  472. and y.delete_sign = 0 <!-- 未删除 -->
  473. </select>
  474. <select id="selectSendMessage" parameterType="java.lang.String" resultType="com.goafanti.message.bo.MessageBo">
  475. <!-- 推送消息 -->
  476. select c.id as messageId,c.title,c.body
  477. from message_producer a inner join jpush_easemob_account b on
  478. a.consumer_id = b.uid
  479. left join message_from_system c on a.message_id = c.id
  480. where
  481. b.registration_id is not null
  482. and a.consumer_id = #{uid,jdbcType=VARCHAR}
  483. and c.is_draft = 0
  484. and c.delete_sign = 0
  485. </select>
  486. <select id="selectJPushAcc" parameterType="java.lang.String" resultType="java.lang.String">
  487. select registration_id from jpush_easemob_account where uid = #{uid,jdbcType=VARCHAR}
  488. </select>
  489. <update id="updateJpushEasemobAccount">
  490. update jpush_easemob_account
  491. <set>
  492. <if test="uuid != null and uuid != ''">
  493. uuid = #{uuid,jdbcType=VARCHAR},
  494. </if>
  495. <if test="registrationId != null and registrationId != ''">
  496. registration_id = #{registrationId,jdbcType=VARCHAR},
  497. </if>
  498. <if test="easemobName != null and easemobName != ''">
  499. easemob_name = #{easemobName,jdbcType=VARCHAR},
  500. </if>
  501. <if test="easemobPass != null and easemobPass != ''">
  502. easemob_pass = #{easemobPass,jdbcType=VARCHAR},
  503. </if>
  504. <if test="lastLoginTime != null">
  505. last_login_time = #{lastLoginTime,jdbcType=TIMESTAMP}
  506. </if>
  507. where uid = #{uid,jdbcType=VARCHAR}
  508. </set>
  509. </update>
  510. <update id="updateMessageConsumer">
  511. update message_consumer
  512. <set>
  513. read_time = #{readTime,jdbcType=TIMESTAMP} where consumer_id = #{uid,jdbcType=VARCHAR} and message_id = #{messageId,jdbcType=VARCHAR}
  514. </set>
  515. </update>
  516. <select id="selectSendTarget" parameterType="java.lang.String" resultType="java.lang.String">
  517. ${sql}
  518. </select>
  519. <select id="selectRecommendTarget" parameterType="java.lang.String" resultType="com.goafanti.common.model.MessageFromSystem">
  520. ${sql}
  521. </select>
  522. <select id="listSystemMessageByPage" resultType="com.goafanti.message.bo.MessageListBo">
  523. select
  524. a.id as messageId,
  525. date_format(a.create_time,'%Y-%m-%d %H:%i:%S') as createTime,
  526. a.creater,
  527. a.consumer_type as consumerType,
  528. a.resource_type as resourceType,
  529. a.title,
  530. a.body,
  531. a.is_draft as isDraft,
  532. a.subject
  533. from
  534. message_from_system a
  535. where 1= 1
  536. <choose>
  537. <when test="subject == 2">
  538. and a.subject = 2
  539. </when>
  540. <otherwise>
  541. and a.subject != 2
  542. </otherwise>
  543. </choose>
  544. <if test="isDraft != null">
  545. and a.is_draft = #{isDraft,jdbcType=INTEGER}
  546. </if>
  547. and a.delete_sign = 0
  548. <if test="page_sql!=null">
  549. ${page_sql}
  550. </if>
  551. </select>
  552. <select id="listSystemMessageCount" resultType="java.lang.Integer">
  553. select
  554. count(0)
  555. from
  556. message_from_system a
  557. where 1= 1
  558. <choose>
  559. <when test="subject == 2">
  560. and a.subject = 2
  561. </when>
  562. <otherwise>
  563. and a.subject != 2
  564. </otherwise>
  565. </choose>
  566. <if test="isDraft != null">
  567. and a.is_draft = #{isDraft,jdbcType=INTEGER}
  568. </if>
  569. and a.delete_sign = 0
  570. </select>
  571. <select id="selectMessageWithGroup" resultType="com.goafanti.app.bo.IndexBo">
  572. select
  573. x.*,y.*
  574. from
  575. (
  576. select
  577. t1.sysMessageTitle,
  578. t1.sysMessageDate,
  579. t2.sysMessageUnRead
  580. from
  581. (
  582. select
  583. title as sysMessageTitle,
  584. date_format(b.create_time,'%Y-%m-%d %H:%i:%S') as sysMessageDate,
  585. 1 as nouse
  586. from
  587. message_consumer a left join message_from_system b on
  588. a.message_id = b.id
  589. where
  590. consumer_id = #{uid,jdbcType=VARCHAR}
  591. and a.read_time is null
  592. and a.delete_sign = 0
  593. and b.subject = 1
  594. order by
  595. a.create_time desc limit 1
  596. ) t1 right join(
  597. select
  598. count(*) as sysMessageUnRead,
  599. 1 as nouse
  600. from
  601. message_consumer a left join message_from_system b on
  602. a.message_id = b.id
  603. where
  604. consumer_id = #{uid,jdbcType=VARCHAR}
  605. and a.read_time is null
  606. and a.delete_sign = 0
  607. and b.subject = 1
  608. ) t2 on
  609. t1.nouse = t2.nouse
  610. ) x,
  611. (
  612. select
  613. t3.recMessageTitle,
  614. t3.recMessageDate,
  615. t4.recMessageUnRead
  616. from
  617. (
  618. select
  619. title as recMessageTitle,
  620. date_format(b.create_time,'%Y-%m-%d %H:%i:%S') as recMessageDate,
  621. 1 as nouse
  622. from
  623. message_consumer a left join message_from_system b on
  624. a.message_id = b.id
  625. where
  626. consumer_id = #{uid,jdbcType=VARCHAR}
  627. and a.read_time is null
  628. and a.delete_sign = 0
  629. and b.subject = 2
  630. order by
  631. a.create_time desc limit 1
  632. ) t3 right join(
  633. select
  634. count(*) as recMessageUnRead,
  635. 1 as nouse
  636. from
  637. message_consumer a left join message_from_system b on
  638. a.message_id = b.id
  639. where
  640. consumer_id = #{uid,jdbcType=VARCHAR}
  641. and a.read_time is null
  642. and a.delete_sign = 0
  643. and b.subject = 2
  644. ) t4 on
  645. t3.nouse = t4.nouse
  646. ) y
  647. </select>
  648. <select id="listPersonalMessageByPage" resultType="com.goafanti.message.bo.MessageListBo">
  649. select
  650. b.id as messageId,b.title,date_format(b.create_time,'%Y-%m-%d %H:%i:%S') as createTime,b.subject,
  651. b.resource_type as resourceType,b.resource_id as resourceId,if(a.read_time is null,0,1) as isRead,b.body as body
  652. from
  653. message_consumer a left join message_from_system b on
  654. a.message_id = b.id
  655. where
  656. a.consumer_id = #{uid,jdbcType=VARCHAR}
  657. and a.delete_sign = 0
  658. <if test="subject != null">
  659. and b.subject = #{subject,jdbcType=INTEGER}
  660. </if>
  661. <if test="resourceType != null">
  662. and b.resource_type = #{resourceType,jdbcType=INTEGER}
  663. </if>
  664. order by isRead,b.create_time DESC
  665. <if test="page_sql!=null">
  666. ${page_sql}
  667. </if>
  668. </select>
  669. <select id="listPersonalMessageCount" resultType="java.lang.Integer">
  670. select
  671. count(0)
  672. from
  673. message_consumer a left join message_from_system b on
  674. a.message_id = b.id
  675. where
  676. a.consumer_id = #{uid,jdbcType=VARCHAR}
  677. and a.delete_sign = 0
  678. <if test="subject != null">
  679. and b.subject = #{subject,jdbcType=INTEGER}
  680. </if>
  681. <if test="resourceType != null">
  682. and b.resource_type = #{resourceType,jdbcType=INTEGER}
  683. </if>
  684. </select>
  685. <select id="appMessageList" resultType="com.goafanti.message.bo.AppMessageBo">
  686. select a.id ,b.title,b.body,b.send_time as sendTime,b.create_time as createTime,a.is_read as isRead from jt_message_consumer a
  687. left join jt_message_producer b on a.message_id=b.id
  688. where a.delete_sign=0 and b.delete_sign=0 and b.is_draft=0 and b.is_send=1
  689. <if test="uid !=null and uid !=''">
  690. and a.aid=#{uid,jdbcType=VARCHAR}
  691. </if>
  692. order by a.is_read ,b.create_time desc
  693. <if test="page_sql!=null">
  694. ${page_sql}
  695. </if>
  696. </select>
  697. <select id="appMessageCount" resultType="java.lang.Integer">
  698. select count(*) from jt_message_consumer a
  699. <if test="uid !=null and uid !=''">
  700. where a.aid=#{uid,jdbcType=VARCHAR}
  701. </if>
  702. </select>
  703. </mapper>