SysMessageMapper.xml 5.4 KB

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