SysMessageMapper.xml 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. <!--
  4. 这个文件是自动生成的。
  5. 不要修改此文件。所有改动将在下次重新自动生成时丢失。
  6. -->
  7. <mapper namespace="com.yonge.cooleshow.biz.dal.dao.SysMessageDao">
  8. <resultMap type="com.yonge.cooleshow.biz.dal.entity.SysMessage" id="message">
  9. <result column="id_" property="id"/>
  10. <result column="title_" property="title"/>
  11. <result column="content_" property="content"/>
  12. <result column="type_" property="type" />
  13. <result column="status_" property="status" />
  14. <result column="receiver_" property="receiver"/>
  15. <result column="send_time_" property="sendTime"/>
  16. <result column="error_msg_" property="errorMsg"/>
  17. <result column="create_on_" property="createOn"/>
  18. <result column="modify_on_" property="modifyOn"/>
  19. <result column="user_id_" property="userId"/>
  20. <result column="message_config_id_" property="messageConfigId"/>
  21. <result column="sub_type_" property="subType"/>
  22. <result column="memo_" property="memo"/>
  23. <result column="read_status_" property="readStatus"/>
  24. <result column="group_" property="group"/>
  25. <result column="client_id_" property="clientId"/>
  26. </resultMap>
  27. <resultMap type="com.yonge.cooleshow.biz.dal.dto.SysMessageDto" id="messageDto" extends="message">
  28. <result column="username_" property="user.username"/>
  29. </resultMap>
  30. <resultMap type="com.yonge.cooleshow.biz.dal.dto.Mapper" id="Mapper">
  31. <result column="key_" property="key"/>
  32. <result column="value_" property="value"/>
  33. </resultMap>
  34. <sql id="queryCondition">
  35. <where>
  36. m.send_time_ &lt;= now()
  37. <if test="clientId != null and clientId != ''">
  38. and (m.client_id_ = #{clientId} OR m.client_id_ IS NULL)
  39. </if>
  40. <if test="userId != null">
  41. and m.user_id_ = #{userId}
  42. </if>
  43. <if test="receiver != null">
  44. and m.receiver_ like '%' #{receiver} '%'
  45. </if>
  46. <if test="status != null">
  47. and m.status_ = #{status,jdbcType=TINYINT}
  48. </if>
  49. <if test="readStatus != null">
  50. and m.read_status_ = #{readStatus,jdbcType=TINYINT}
  51. </if>
  52. <if test="title != null">
  53. and m.title_ like '%' #{title} '%'
  54. </if>
  55. <if test="type != null">
  56. and m.type_ = #{type}
  57. </if>
  58. <if test="group != null">
  59. and m.group_ = #{group}
  60. </if>
  61. <if test="readStatus != null">
  62. and m.read_status_ = #{readStatus}
  63. </if>
  64. </where>
  65. </sql>
  66. <select id="get" resultMap="message" parameterType="java.lang.Long">
  67. select *
  68. from sys_message
  69. where id_ = #{id,jdbcType=BIGINT}
  70. </select>
  71. <delete id="delete" parameterType="java.lang.Long">
  72. delete from
  73. sys_message
  74. where
  75. id_ = #{id,jdbcType=BIGINT}
  76. </delete>
  77. <insert id="insert" parameterType="com.yonge.cooleshow.biz.dal.entity.SysMessage">
  78. insert into sys_message (user_id_,title_, content_,type_, receiver_,
  79. send_time_, error_msg_,memo_, create_on_,modify_on_,group_,client_id_,message_config_id_)
  80. values (#{userId}, #{title},#{content},#{type},
  81. #{receiver},now(),#{errorMsg},#{memo},now(),now(),#{group},#{clientId},#{messageConfigId})
  82. </insert>
  83. <insert id="batchInsert" parameterType="com.yonge.cooleshow.biz.dal.entity.SysMessage">
  84. insert into sys_message (id_, user_id_,
  85. title_, content_,
  86. type_, status_, receiver_,
  87. send_time_, error_msg_,read_status_,memo_, create_on_,
  88. modify_on_,group_,client_id_,message_config_id_)
  89. values
  90. <foreach collection="list" item="item" index="index"
  91. separator=",">
  92. (
  93. #{item.id,jdbcType=BIGINT},#{item.userId,jdbcType=BIGINT}, #{item.title,jdbcType=VARCHAR},
  94. #{item.content,jdbcType=VARCHAR},
  95. #{item.type},
  96. #{item.status}, #{item.receiver,jdbcType=VARCHAR},
  97. #{item.sendTime},#{item.errorMsg,jdbcType=VARCHAR},#{item.readStatus},#{item.memo},
  98. #{item.createOn},
  99. #{item.modifyOn},#{item.group},#{item.clientId},#{item.messageConfigId})
  100. </foreach>
  101. </insert>
  102. <update id="update" parameterType="com.yonge.cooleshow.biz.dal.entity.SysMessage">
  103. update sys_message
  104. <set>
  105. <if test="userId != null">
  106. user_id_ = #{userId,jdbcType=BIGINT},
  107. </if>
  108. <if test="title != null">
  109. title_ = #{title,jdbcType=VARCHAR},
  110. </if>
  111. <if test="content != null">
  112. content_ = #{content,jdbcType=VARCHAR},
  113. </if>
  114. <if test="type != null">
  115. type_ = #{type},
  116. </if>
  117. <if test="status != null">
  118. status_ = #{status},
  119. </if>
  120. <if test="receiver != null">
  121. receiver_ = #{receiver,jdbcType=VARCHAR},
  122. </if>
  123. <if test="sendTime != null">
  124. send_time_ = #{sendTime},
  125. </if>
  126. <if test="errorMsg != null">
  127. error_msg_ = #{errorMsg,jdbcType=VARCHAR},
  128. </if>
  129. <if test="readStatus != null">
  130. read_status_ = #{readStatus,jdbcType=TINYINT},
  131. </if>
  132. <if test="memo != null">
  133. memo_ = #{memo,jdbcType=VARCHAR},
  134. </if>
  135. <if test="createOn != null">
  136. create_on_ = #{createOn},
  137. </if>
  138. <if test="modifyOn != null">
  139. modify_on_ = #{modifyOn},
  140. </if>
  141. <if test="group != null">
  142. group_ = #{group},
  143. </if>
  144. <if test="messageConfigId != null">
  145. message_config_id_ = #{messageConfigId},
  146. </if>
  147. </set>
  148. where id_ = #{id,jdbcType=BIGINT}
  149. </update>
  150. <update id="updateStatus">
  151. update sys_message set read_status_=#{status}
  152. where user_id_ = #{userId} AND (client_id_ = #{jpushType} OR client_id_ IS NULL)
  153. </update>
  154. <update id="updateOneStatus">
  155. update sys_message set read_status_=#{status}
  156. where id_ =#{id}
  157. </update>
  158. <select id="queryCount" parameterType="map" resultType="int">
  159. select count(m.id_) from sys_message m
  160. <include refid="queryCondition" />
  161. order by m.create_on_ desc
  162. </select>
  163. <select id="queryPage" parameterType="map" resultMap="message">
  164. select m.*,
  165. smc.sub_type_
  166. from sys_message m
  167. left join sys_message_config smc on m.message_config_id_ = smc.id_
  168. <include refid="queryCondition" />
  169. order by m.create_on_ desc
  170. <include refid="global.limit" />
  171. </select>
  172. <select id="queryListPage" parameterType="map" resultMap="messageDto">
  173. select m.*,u.username_ from sys_message m left join sys_user u on m.user_id_ = u.id_
  174. <include refid="queryCondition" />
  175. order by m.create_on_ desc
  176. <include refid="global.limit" />
  177. </select>
  178. <select id="queryByStatusAndTime" resultMap="message">
  179. select *
  180. from sys_message where status_ = #{status} and <![CDATA[DATE_ADD(CURDATE(),
  181. INTERVAL #{recentMin} MINUTE) >= date(send_time_)]]>
  182. </select>
  183. <select id="queryCountOfUnread" resultMap="Mapper" parameterType="map">
  184. SELECT group_ key_,COUNT(*) value_ FROM sys_message
  185. WHERE user_id_ = #{userId} AND read_status_ = 0 and status_ = 2
  186. AND (client_id_ = #{jpushType} OR client_id_ IS NULL) and send_time_ &lt;= now()
  187. <if test="type != null">
  188. and type_ = #{type}
  189. </if>
  190. group by group_
  191. </select>
  192. <select id="queryUserInRecentMinList" resultMap="message" parameterType="map">
  193. select *
  194. from sys_message where receiver_ = #{mobile} and type_ = #{type} and <![CDATA[DATE_ADD(send_time_,
  195. INTERVAL #{recentMin} MINUTE) >= now()]]>
  196. </select>
  197. <select id="selectConfigUrl" resultType="java.lang.String" parameterType="java.lang.String">
  198. SELECT url_ FROM sys_message_config WHERE message_type_=#{messageType}
  199. </select>
  200. </mapper>