SysMessageMapper.xml 5.6 KB

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