SysMessageMapper.xml 6.2 KB

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