SysMessageMapper.xml 7.0 KB

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