SysMessageMapper.xml 7.3 KB

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