SysMessageMapper.xml 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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 (id_, user_id_,
  62. title_, content_,
  63. type_, status_, receiver_,
  64. send_time_, error_msg_,read_status_,memo_, create_on_,
  65. modify_on_,group_)
  66. values (#{id,jdbcType=BIGINT},#{userId,jdbcType=BIGINT}, #{title,jdbcType=VARCHAR},
  67. #{content,jdbcType=VARCHAR},
  68. #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  69. #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{receiver,jdbcType=VARCHAR},
  70. #{sendTime},#{errorMsg,jdbcType=VARCHAR},#{readStatus},#{memo},
  71. #{createOn},
  72. #{modifyOn},#{group})
  73. </insert>
  74. <insert id="batchInsert" parameterType="com.ym.mec.biz.dal.entity.SysMessage">
  75. insert into sys_message (id_, user_id_,
  76. title_, content_,
  77. type_, status_, receiver_,
  78. send_time_, error_msg_,read_status_,memo_, create_on_,
  79. modify_on_,group_)
  80. values
  81. <foreach collection="list" item="item" index="index"
  82. separator=",">
  83. (
  84. #{item.id,jdbcType=BIGINT},#{item.userId,jdbcType=BIGINT}, #{item.title,jdbcType=VARCHAR},
  85. #{item.content,jdbcType=VARCHAR},
  86. #{item.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  87. #{item.status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{item.receiver,jdbcType=VARCHAR},
  88. #{item.sendTime},#{item.errorMsg,jdbcType=VARCHAR},#{item.readStatus},#{item.memo},
  89. #{item.createOn},
  90. #{item.modifyOn},#{item.group}
  91. )
  92. </foreach>
  93. </insert>
  94. <update id="update" parameterType="com.ym.mec.biz.dal.entity.SysMessage">
  95. update sys_message
  96. <set>
  97. <if test="userId != null">
  98. user_id_ = #{userId,jdbcType=BIGINT},
  99. </if>
  100. <if test="title != null">
  101. title_ = #{title,jdbcType=VARCHAR},
  102. </if>
  103. <if test="content != null">
  104. content_ = #{content,jdbcType=VARCHAR},
  105. </if>
  106. <if test="type != null">
  107. type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  108. </if>
  109. <if test="status != null">
  110. status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  111. </if>
  112. <if test="receiver != null">
  113. receiver_ = #{receiver,jdbcType=VARCHAR},
  114. </if>
  115. <if test="sendTime != null">
  116. send_time_ = #{sendTime},
  117. </if>
  118. <if test="errorMsg != null">
  119. error_msg_ = #{errorMsg,jdbcType=VARCHAR},
  120. </if>
  121. <if test="readStatus != null">
  122. read_status_ = #{readStatus,jdbcType=TINYINT},
  123. </if>
  124. <if test="memo != null">
  125. memo_ = #{memo,jdbcType=VARCHAR},
  126. </if>
  127. <if test="createOn != null">
  128. create_on_ = #{createOn},
  129. </if>
  130. <if test="modifyOn != null">
  131. modify_on_ = #{modifyOn},
  132. </if>
  133. <if test="group != null">
  134. group_ = #{group},
  135. </if>
  136. </set>
  137. where id_ = #{id,jdbcType=BIGINT}
  138. </update>
  139. <update id="updateStatus">
  140. update sys_message set read_status_=#{status}
  141. where user_id_ =#{userId}
  142. </update>
  143. <update id="updateOneStatus">
  144. update sys_message set read_status_=#{status}
  145. where id_ =#{id}
  146. </update>
  147. <select id="queryCount" parameterType="map" resultType="int">
  148. select count(*) from sys_message
  149. <include refid="queryCondition" />
  150. </select>
  151. <select id="queryPage" parameterType="map" resultMap="message">
  152. select * from sys_message
  153. <include refid="queryCondition" />
  154. order by create_on_ desc
  155. <include refid="global.limit" />
  156. </select>
  157. <select id="queryByStatusAndTime" resultMap="message">
  158. select *
  159. from sys_message where status_ = #{status} and <![CDATA[DATE_ADD(CURDATE(),
  160. INTERVAL #{recentMin} MINUTE) >= date(send_time_)]]>
  161. </select>
  162. <select id="queryCountOfUnread" resultType="int">
  163. select count(*) from sys_message
  164. where user_id_ = #{userId} and read_status_ = 0
  165. </select>
  166. </mapper>