审查视图

src/main/resources/mapper/MessageNoteMapper.xml 12.7 KB
王勇 authored
1 2 3
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.sunyo.wlpt.message.bus.service.mapper.MessageNoteMapper">
王勇 authored
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
    <resultMap id="BaseResultMap" type="com.sunyo.wlpt.message.bus.service.domain.MessageNote">
        <!--@mbg.generated-->
        <!--@Table message_note-->
        <id column="id" jdbcType="VARCHAR" property="id"/>
    <result column="user_id" jdbcType="VARCHAR" property="userId"/>
    <result column="username" jdbcType="VARCHAR" property="username"/>
    <result column="server_id" jdbcType="VARCHAR" property="serverId"/>
    <result column="server_name" jdbcType="VARCHAR" property="serverName"/>
    <result column="virtual_host_id" jdbcType="VARCHAR" property="virtualHostId"/>
    <result column="virtual_host_name" jdbcType="VARCHAR" property="virtualHostName"/>
    <result column="exchange_id" jdbcType="VARCHAR" property="exchangeId"/>
    <result column="exchange_name" jdbcType="VARCHAR" property="exchangeName"/>
    <result column="queue_id" jdbcType="VARCHAR" property="queueId"/>
    <result column="queue_name" jdbcType="VARCHAR" property="queueName"/>
    <result column="routing_key_id" jdbcType="VARCHAR" property="routingKeyId"/>
    <result column="routing_key_name" jdbcType="VARCHAR" property="routingKeyName"/>
    <result column="send_time" jdbcType="TIMESTAMP" property="sendTime"/>
    <result column="receive_time" jdbcType="TIMESTAMP" property="receiveTime"/>
    <result column="send_content" jdbcType="BLOB" property="sendContent"/>
    <result column="description" jdbcType="VARCHAR" property="description"/>
    <result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate"/>
    <result column="gmt_modified" jdbcType="TIMESTAMP" property="gmtModified"/>
    </resultMap>
27
  <sql id="Base_Column_List">
王勇 authored
28 29
      <!--@mbg.generated-->
      id, user_id, username, server_id, `server_name`, virtual_host_id, virtual_host_name,
30 31
    exchange_id, exchange_name, queue_id, queue_name, routing_key_id, routing_key_name, 
    send_time, receive_time, send_content, description, gmt_create, gmt_modified
32 33
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
王勇 authored
34 35 36 37 38
      <!--@mbg.generated-->
      select
      <include refid="Base_Column_List"/>
      from message_note
      where id = #{id,jdbcType=VARCHAR}
39 40
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
王勇 authored
41 42 43 44
      <!--@mbg.generated-->
      delete
      from message_note
      where id = #{id,jdbcType=VARCHAR}
45 46
  </delete>
  <insert id="insert" parameterType="com.sunyo.wlpt.message.bus.service.domain.MessageNote">
王勇 authored
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
      <!--@mbg.generated-->
      insert into message_note (id, user_id, username,
                                server_id, `server_name`, virtual_host_id,
                                virtual_host_name, exchange_id, exchange_name,
                                queue_id, queue_name, routing_key_id,
                                routing_key_name, send_time, receive_time,
                                send_content, description, gmt_create,
                                gmt_modified)
      values (#{id,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}, #{username,jdbcType=VARCHAR},
              #{serverId,jdbcType=VARCHAR}, #{serverName,jdbcType=VARCHAR}, #{virtualHostId,jdbcType=VARCHAR},
              #{virtualHostName,jdbcType=VARCHAR}, #{exchangeId,jdbcType=VARCHAR}, #{exchangeName,jdbcType=VARCHAR},
              #{queueId,jdbcType=VARCHAR}, #{queueName,jdbcType=VARCHAR}, #{routingKeyId,jdbcType=VARCHAR},
              #{routingKeyName,jdbcType=VARCHAR}, #{sendTime,jdbcType=TIMESTAMP}, #{receiveTime,jdbcType=TIMESTAMP},
              #{sendContent,jdbcType=BLOB}, #{description,jdbcType=VARCHAR}, #{gmtCreate,jdbcType=TIMESTAMP},
              #{gmtModified,jdbcType=TIMESTAMP})
62 63
  </insert>
  <insert id="insertSelective" parameterType="com.sunyo.wlpt.message.bus.service.domain.MessageNote">
王勇 authored
64 65 66 67 68 69
      <!--@mbg.generated-->
      insert into message_note
      <trim prefix="(" suffix=")" suffixOverrides=",">
          <if test="id != null">
              id,
          </if>
70
      <if test="userId != null">
王勇 authored
71
          user_id,
72 73
      </if>
      <if test="username != null">
王勇 authored
74
          username,
75 76
      </if>
      <if test="serverId != null">
王勇 authored
77
          server_id,
78 79
      </if>
      <if test="serverName != null">
王勇 authored
80
          `server_name`,
81 82
      </if>
      <if test="virtualHostId != null">
王勇 authored
83
          virtual_host_id,
84 85
      </if>
      <if test="virtualHostName != null">
王勇 authored
86
          virtual_host_name,
87 88
      </if>
      <if test="exchangeId != null">
王勇 authored
89
          exchange_id,
90 91
      </if>
      <if test="exchangeName != null">
王勇 authored
92
          exchange_name,
93 94
      </if>
      <if test="queueId != null">
王勇 authored
95
          queue_id,
96 97
      </if>
      <if test="queueName != null">
王勇 authored
98
          queue_name,
99 100
      </if>
      <if test="routingKeyId != null">
王勇 authored
101
          routing_key_id,
102 103
      </if>
      <if test="routingKeyName != null">
王勇 authored
104
          routing_key_name,
105 106
      </if>
      <if test="sendTime != null">
王勇 authored
107
          send_time,
108 109
      </if>
      <if test="receiveTime != null">
王勇 authored
110
          receive_time,
111 112
      </if>
      <if test="sendContent != null">
王勇 authored
113
          send_content,
114
      </if>
115
      <if test="description != null">
王勇 authored
116
          description,
117
      </if>
118
      <if test="gmtCreate != null">
王勇 authored
119
          gmt_create,
120 121
      </if>
      <if test="gmtModified != null">
王勇 authored
122
          gmt_modified,
123
      </if>
王勇 authored
124
      </trim>
125
    <trim prefix="values (" suffix=")" suffixOverrides=",">
王勇 authored
126 127 128
        <if test="id != null">
            #{id,jdbcType=VARCHAR},
        </if>
129
      <if test="userId != null">
王勇 authored
130
          #{userId,jdbcType=VARCHAR},
131 132
      </if>
      <if test="username != null">
王勇 authored
133
          #{username,jdbcType=VARCHAR},
134 135
      </if>
      <if test="serverId != null">
王勇 authored
136
          #{serverId,jdbcType=VARCHAR},
137 138
      </if>
      <if test="serverName != null">
王勇 authored
139
          #{serverName,jdbcType=VARCHAR},
140 141
      </if>
      <if test="virtualHostId != null">
王勇 authored
142
          #{virtualHostId,jdbcType=VARCHAR},
143 144
      </if>
      <if test="virtualHostName != null">
王勇 authored
145
          #{virtualHostName,jdbcType=VARCHAR},
146 147
      </if>
      <if test="exchangeId != null">
王勇 authored
148
          #{exchangeId,jdbcType=VARCHAR},
149 150
      </if>
      <if test="exchangeName != null">
王勇 authored
151
          #{exchangeName,jdbcType=VARCHAR},
152 153
      </if>
      <if test="queueId != null">
王勇 authored
154
          #{queueId,jdbcType=VARCHAR},
155 156
      </if>
      <if test="queueName != null">
王勇 authored
157
          #{queueName,jdbcType=VARCHAR},
158 159
      </if>
      <if test="routingKeyId != null">
王勇 authored
160
          #{routingKeyId,jdbcType=VARCHAR},
161 162
      </if>
      <if test="routingKeyName != null">
王勇 authored
163
          #{routingKeyName,jdbcType=VARCHAR},
164 165
      </if>
      <if test="sendTime != null">
王勇 authored
166
          #{sendTime,jdbcType=TIMESTAMP},
167 168
      </if>
      <if test="receiveTime != null">
王勇 authored
169
          #{receiveTime,jdbcType=TIMESTAMP},
170 171
      </if>
      <if test="sendContent != null">
王勇 authored
172
          #{sendContent,jdbcType=BLOB},
173
      </if>
174
      <if test="description != null">
王勇 authored
175
          #{description,jdbcType=VARCHAR},
176
      </if>
177
      <if test="gmtCreate != null">
王勇 authored
178
          #{gmtCreate,jdbcType=TIMESTAMP},
179 180
      </if>
      <if test="gmtModified != null">
王勇 authored
181
          #{gmtModified,jdbcType=TIMESTAMP},
182 183 184 185
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.sunyo.wlpt.message.bus.service.domain.MessageNote">
王勇 authored
186 187 188 189 190 191
      <!--@mbg.generated-->
      update message_note
      <set>
          <if test="userId != null">
              user_id = #{userId,jdbcType=VARCHAR},
          </if>
192
      <if test="username != null">
王勇 authored
193
          username = #{username,jdbcType=VARCHAR},
194 195
      </if>
      <if test="serverId != null">
王勇 authored
196
          server_id = #{serverId,jdbcType=VARCHAR},
197 198
      </if>
      <if test="serverName != null">
王勇 authored
199
          `server_name` = #{serverName,jdbcType=VARCHAR},
200 201
      </if>
      <if test="virtualHostId != null">
王勇 authored
202
          virtual_host_id = #{virtualHostId,jdbcType=VARCHAR},
203 204
      </if>
      <if test="virtualHostName != null">
王勇 authored
205
          virtual_host_name = #{virtualHostName,jdbcType=VARCHAR},
206 207
      </if>
      <if test="exchangeId != null">
王勇 authored
208
          exchange_id = #{exchangeId,jdbcType=VARCHAR},
209 210
      </if>
      <if test="exchangeName != null">
王勇 authored
211
          exchange_name = #{exchangeName,jdbcType=VARCHAR},
212 213
      </if>
      <if test="queueId != null">
王勇 authored
214
          queue_id = #{queueId,jdbcType=VARCHAR},
215 216
      </if>
      <if test="queueName != null">
王勇 authored
217
          queue_name = #{queueName,jdbcType=VARCHAR},
218 219
      </if>
      <if test="routingKeyId != null">
王勇 authored
220
          routing_key_id = #{routingKeyId,jdbcType=VARCHAR},
221 222
      </if>
      <if test="routingKeyName != null">
王勇 authored
223
          routing_key_name = #{routingKeyName,jdbcType=VARCHAR},
224 225
      </if>
      <if test="sendTime != null">
王勇 authored
226
          send_time = #{sendTime,jdbcType=TIMESTAMP},
227 228
      </if>
      <if test="receiveTime != null">
王勇 authored
229
          receive_time = #{receiveTime,jdbcType=TIMESTAMP},
230 231
      </if>
      <if test="sendContent != null">
王勇 authored
232
          send_content = #{sendContent,jdbcType=BLOB},
233
      </if>
234
      <if test="description != null">
王勇 authored
235
          description = #{description,jdbcType=VARCHAR},
236
      </if>
237
      <if test="gmtCreate != null">
王勇 authored
238
          gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
239 240
      </if>
      <if test="gmtModified != null">
王勇 authored
241
          gmt_modified = #{gmtModified,jdbcType=TIMESTAMP},
242
      </if>
王勇 authored
243 244
      </set>
      where id = #{id,jdbcType=VARCHAR}
245 246
  </update>
  <update id="updateByPrimaryKey" parameterType="com.sunyo.wlpt.message.bus.service.domain.MessageNote">
王勇 authored
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
      <!--@mbg.generated-->
      update message_note
      set user_id           = #{userId,jdbcType=VARCHAR},
          username          = #{username,jdbcType=VARCHAR},
          server_id         = #{serverId,jdbcType=VARCHAR},
          `server_name`     = #{serverName,jdbcType=VARCHAR},
          virtual_host_id   = #{virtualHostId,jdbcType=VARCHAR},
          virtual_host_name = #{virtualHostName,jdbcType=VARCHAR},
          exchange_id       = #{exchangeId,jdbcType=VARCHAR},
          exchange_name     = #{exchangeName,jdbcType=VARCHAR},
          queue_id          = #{queueId,jdbcType=VARCHAR},
          queue_name        = #{queueName,jdbcType=VARCHAR},
          routing_key_id    = #{routingKeyId,jdbcType=VARCHAR},
          routing_key_name  = #{routingKeyName,jdbcType=VARCHAR},
          send_time         = #{sendTime,jdbcType=TIMESTAMP},
          receive_time      = #{receiveTime,jdbcType=TIMESTAMP},
          send_content      = #{sendContent,jdbcType=BLOB},
          description       = #{description,jdbcType=VARCHAR},
          gmt_create        = #{gmtCreate,jdbcType=TIMESTAMP},
          gmt_modified      = #{gmtModified,jdbcType=TIMESTAMP}
      where id = #{id,jdbcType=VARCHAR}
268
  </update>
269
王勇 authored
270
    <!-- 获取,消息收发记录列表 -->
王勇 authored
271 272
    <select id="selectMessageNoteList" parameterType="com.sunyo.wlpt.message.bus.service.domain.MessageNote"
            resultMap="BaseResultMap">
王勇 authored
273
        select
王勇 authored
274
        <include refid="Base_Column_List"/>
王勇 authored
275 276 277
        from message_note
        <where>
            <!-- 所属用户登陆名称 -->
王勇 authored
278
            <if test="username != null and username != ''">
王勇 authored
279 280 281
                username = #{username,jdbcType=VARCHAR}
            </if>
            <!-- 所属服务器名称 -->
王勇 authored
282
            <if test="serverName != null and serverName != ''">
王勇 authored
283 284 285
                AND server_name = #{serverName,jdbcType=VARCHAR}
            </if>
            <!-- 所属虚拟主机名称 -->
王勇 authored
286
            <if test="virtualHostName != null and virtualHostName != ''">
王勇 authored
287 288 289
                AND virtual_host_name = #{virtualHostName,jdbcType=VARCHAR}
            </if>
            <!-- 所属交换机名称 -->
王勇 authored
290
            <if test="exchangeName != null and exchangeName != ''">
王勇 authored
291 292 293
                AND exchange_name = #{exchangeName,jdbcType=VARCHAR}
            </if>
            <!-- 所属路由键名称 -->
王勇 authored
294
            <if test="routingKeyName != null and routingKeyName != ''">
王勇 authored
295 296 297
                AND routing_key_name = #{routingKeyName,jdbcType=VARCHAR}
            </if>
            <!-- 所属队列名称 -->
王勇 authored
298
            <if test="queueName != null and queueName != ''">
王勇 authored
299 300 301 302
                AND queue_name = #{queueName,jdbcType=VARCHAR}
            </if>
            <!-- 消息发送时间 -->
            <if test="sendTime != null">
王勇 authored
303
                AND DATE_FORMAT(send_time, '%Y-%m-%d') = #{sendTime,jdbcType=DATE}
王勇 authored
304 305 306
            </if>
            <!-- 消息接收时间 -->
            <if test="receiveTime != null">
王勇 authored
307
                AND DATE_FORMAT(receive_time, '%Y-%m-%d') = #{receiveTime,jdbcType=DATE}
王勇 authored
308 309 310
            </if>
        </where>
    </select>
311 312
    <!--  自动删除 message_note记录 -->
    <delete id="autoDelete" parameterType="java.lang.Integer">
王勇 authored
313 314 315
        delete
        from message_note
        where to_days(now()) - to_days(gmt_create) &gt;= #{deleteTime,jdbcType=INTEGER}
316
    </delete>
317
</mapper>