审查视图

src/main/resources/mapper/UserMessageBindingMapper.xml 18.6 KB
王勇 authored
1 2
<?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">
王勇 authored
3
<mapper namespace="com.sunyo.wlpt.message.bus.service.mapper.UserMessageBindingMapper">
4
    <cache type="com.sunyo.wlpt.message.bus.service.cache.RedisCache"/>
王勇 authored
5 6 7
    <resultMap id="BaseResultMap" type="com.sunyo.wlpt.message.bus.service.domain.UserMessageBinding">
        <!--@mbg.generated--><!--@Table user_message_binding-->
        <id column="id" jdbcType="VARCHAR" property="id"/>
王勇 authored
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
        <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="subscriber" jdbcType="VARCHAR" property="subscriber"/>
        <result column="description" jdbcType="VARCHAR" property="description"/>
        <result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate"/>
        <result column="gmt_modified" jdbcType="TIMESTAMP" property="gmtModified"/>
王勇 authored
24
    </resultMap>
王勇 authored
25
26
  <sql id="Base_Column_List">
王勇 authored
27
      <!--@mbg.generated-->id, user_id, username, server_id, `server_name`, virtual_host_id, virtual_host_name,
王勇 authored
28
    exchange_id, exchange_name, queue_id, queue_name, routing_key_id, routing_key_name,
29
    subscriber, description, gmt_create, gmt_modified
30
  </sql>
王勇 authored
31
32
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
33 34
      <!--@mbg.generated-->
      select
王勇 authored
35 36 37
      <include refid="Base_Column_List"/>
      from user_message_binding
      where id = #{id,jdbcType=VARCHAR}
38
  </select>
39
40 41 42 43 44 45 46 47
  <select id="selectByRoutingKeyId" parameterType="java.lang.String" resultMap="BaseResultMap">
      <!--@mbg.generated-->
      select
      <include refid="Base_Column_List"/>
      from user_message_binding
      where routing_key_id = #{routingKeyId,jdbcType=VARCHAR}
  </select>
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
    <select id="selectByServerId" parameterType="java.lang.String" resultMap="BaseResultMap">
        <!--@mbg.generated-->
        select
        <include refid="Base_Column_List"/>
        from user_message_binding
        where server_id = #{serverId,jdbcType=VARCHAR}
    </select>

  <select id="selectByVirtualHostId" parameterType="java.lang.String" resultMap="BaseResultMap">
      <!--@mbg.generated-->
      select
      <include refid="Base_Column_List"/>
      from user_message_binding
      where virtual_host_id = #{virtualHostId,jdbcType=VARCHAR}
  </select>
64
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
65 66 67 68
      <!--@mbg.generated-->
      delete
      from user_message_binding
      where id = #{id,jdbcType=VARCHAR}
69
  </delete>
70
71
    <!--  根据服务器id,删除配置关系-->
72 73 74 75 76 77 78 79 80 81 82 83 84
    <delete id="deleteByServerId" parameterType="java.lang.String">
        <!--@mbg.generated-->
        delete
        from user_message_binding
        where server_id = #{serverId,jdbcType=VARCHAR}
    </delete>
    <!--  根据虚拟主机id,删除配置关系-->
    <delete id="deleteByVirtualHostId" parameterType="java.lang.String">
        <!--@mbg.generated-->
        delete
        from user_message_binding
        where virtual_host_id = #{virtualHostId,jdbcType=VARCHAR}
    </delete>
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
    <!--  根据交换机id,删除配置关系-->
    <delete id="deleteByExchangeId" parameterType="java.lang.String">
        <!--@mbg.generated-->
        delete
        from user_message_binding
        where exchange_id = #{exchangeId,jdbcType=VARCHAR}
    </delete>

    <!--  根据队列id,删除配置关系-->
    <delete id="deleteByQueueId" parameterType="java.lang.String">
        <!--@mbg.generated-->
        delete
        from user_message_binding
        where queue_id = #{queueId,jdbcType=VARCHAR}
    </delete>
100 101 102 103 104 105 106 107 108

    <!--  根据路由键id,删除配置关系-->
    <delete id="deleteByRoutingKeyId" parameterType="java.lang.String">
        <!--@mbg.generated-->
        delete
        from user_message_binding
        where routing_key_id = #{routingKeyId,jdbcType=VARCHAR}
    </delete>
109
  <insert id="insert" parameterType="com.sunyo.wlpt.message.bus.service.domain.UserMessageBinding">
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
      <!--@mbg.generated-->
      insert into user_message_binding (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, subscriber, 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}, #{subscriber,jdbcType=VARCHAR},
              #{description,jdbcType=VARCHAR},
              #{gmtCreate,jdbcType=TIMESTAMP}, #{gmtModified,jdbcType=TIMESTAMP})
127 128
  </insert>
  <insert id="insertSelective" parameterType="com.sunyo.wlpt.message.bus.service.domain.UserMessageBinding">
129 130
      <!--@mbg.generated-->
      insert into user_message_binding
王勇 authored
131 132 133 134
      <trim prefix="(" suffix=")" suffixOverrides=",">
          <if test="id != null">
              id,
          </if>
135 136 137
          <if test="userId != null">
              user_id,
          </if>
138
      <if test="username != null">
王勇 authored
139
          username,
140
      </if>
王勇 authored
141
      <if test="serverId != null">
王勇 authored
142
          server_id,
王勇 authored
143 144
      </if>
      <if test="serverName != null">
王勇 authored
145
          `server_name`,
王勇 authored
146
      </if>
147
      <if test="virtualHostId != null">
王勇 authored
148
          virtual_host_id,
149 150
      </if>
      <if test="virtualHostName != null">
王勇 authored
151
          virtual_host_name,
152 153
      </if>
      <if test="exchangeId != null">
王勇 authored
154
          exchange_id,
155 156
      </if>
      <if test="exchangeName != null">
王勇 authored
157
          exchange_name,
158 159
      </if>
      <if test="queueId != null">
王勇 authored
160
          queue_id,
161 162
      </if>
      <if test="queueName != null">
王勇 authored
163
          queue_name,
164 165
      </if>
      <if test="routingKeyId != null">
王勇 authored
166
          routing_key_id,
167 168
      </if>
      <if test="routingKeyName != null">
王勇 authored
169
          routing_key_name,
170 171
      </if>
      <if test="subscriber != null">
王勇 authored
172
          subscriber,
173
      </if>
174
      <if test="description != null">
王勇 authored
175
          description,
176
      </if>
177
      <if test="gmtCreate != null">
王勇 authored
178
          gmt_create,
179 180
      </if>
      <if test="gmtModified != null">
王勇 authored
181
          gmt_modified,
182
      </if>
王勇 authored
183
      </trim>
184
    <trim prefix="values (" suffix=")" suffixOverrides=",">
王勇 authored
185 186 187
        <if test="id != null">
            #{id,jdbcType=VARCHAR},
        </if>
188
      <if test="userId != null">
王勇 authored
189
          #{userId,jdbcType=VARCHAR},
190 191
      </if>
      <if test="username != null">
王勇 authored
192
          #{username,jdbcType=VARCHAR},
193
      </if>
王勇 authored
194
      <if test="serverId != null">
王勇 authored
195
          #{serverId,jdbcType=VARCHAR},
王勇 authored
196 197
      </if>
      <if test="serverName != null">
王勇 authored
198
          #{serverName,jdbcType=VARCHAR},
王勇 authored
199
      </if>
200
      <if test="virtualHostId != null">
王勇 authored
201
          #{virtualHostId,jdbcType=VARCHAR},
202 203
      </if>
      <if test="virtualHostName != null">
王勇 authored
204
          #{virtualHostName,jdbcType=VARCHAR},
205 206
      </if>
      <if test="exchangeId != null">
王勇 authored
207
          #{exchangeId,jdbcType=VARCHAR},
208 209
      </if>
      <if test="exchangeName != null">
王勇 authored
210
          #{exchangeName,jdbcType=VARCHAR},
211 212
      </if>
      <if test="queueId != null">
王勇 authored
213
          #{queueId,jdbcType=VARCHAR},
214 215
      </if>
      <if test="queueName != null">
王勇 authored
216
          #{queueName,jdbcType=VARCHAR},
217 218
      </if>
      <if test="routingKeyId != null">
王勇 authored
219
          #{routingKeyId,jdbcType=VARCHAR},
220 221
      </if>
      <if test="routingKeyName != null">
王勇 authored
222
          #{routingKeyName,jdbcType=VARCHAR},
223 224
      </if>
      <if test="subscriber != null">
王勇 authored
225
          #{subscriber,jdbcType=VARCHAR},
226
      </if>
227
      <if test="description != null">
王勇 authored
228
          #{description,jdbcType=VARCHAR},
229
      </if>
230
      <if test="gmtCreate != null">
王勇 authored
231
          #{gmtCreate,jdbcType=TIMESTAMP},
232 233
      </if>
      <if test="gmtModified != null">
王勇 authored
234
          #{gmtModified,jdbcType=TIMESTAMP},
235 236 237 238
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.sunyo.wlpt.message.bus.service.domain.UserMessageBinding">
239 240
      <!--@mbg.generated-->
      update user_message_binding
王勇 authored
241 242 243 244
      <set>
          <if test="userId != null">
              user_id = #{userId,jdbcType=VARCHAR},
          </if>
245
      <if test="username != null">
王勇 authored
246
          username = #{username,jdbcType=VARCHAR},
247
      </if>
王勇 authored
248
      <if test="serverId != null">
王勇 authored
249
          server_id = #{serverId,jdbcType=VARCHAR},
王勇 authored
250 251
      </if>
      <if test="serverName != null">
王勇 authored
252
          `server_name` = #{serverName,jdbcType=VARCHAR},
王勇 authored
253
      </if>
254
      <if test="virtualHostId != null">
王勇 authored
255
          virtual_host_id = #{virtualHostId,jdbcType=VARCHAR},
256 257
      </if>
      <if test="virtualHostName != null">
王勇 authored
258
          virtual_host_name = #{virtualHostName,jdbcType=VARCHAR},
259 260
      </if>
      <if test="exchangeId != null">
王勇 authored
261
          exchange_id = #{exchangeId,jdbcType=VARCHAR},
262 263
      </if>
      <if test="exchangeName != null">
王勇 authored
264
          exchange_name = #{exchangeName,jdbcType=VARCHAR},
265 266
      </if>
      <if test="queueId != null">
王勇 authored
267
          queue_id = #{queueId,jdbcType=VARCHAR},
268 269
      </if>
      <if test="queueName != null">
王勇 authored
270
          queue_name = #{queueName,jdbcType=VARCHAR},
271 272
      </if>
      <if test="routingKeyId != null">
王勇 authored
273
          routing_key_id = #{routingKeyId,jdbcType=VARCHAR},
274 275
      </if>
      <if test="routingKeyName != null">
王勇 authored
276
          routing_key_name = #{routingKeyName,jdbcType=VARCHAR},
277 278
      </if>
      <if test="subscriber != null">
王勇 authored
279
          subscriber = #{subscriber,jdbcType=VARCHAR},
280
      </if>
281
      <if test="description != null">
王勇 authored
282
          description = #{description,jdbcType=VARCHAR},
283
      </if>
284
      <if test="gmtCreate != null">
王勇 authored
285
          gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
286 287
      </if>
      <if test="gmtModified != null">
王勇 authored
288
          gmt_modified = #{gmtModified,jdbcType=TIMESTAMP},
289
      </if>
王勇 authored
290 291 292
      </set>

      where id = #{id,jdbcType=VARCHAR}
293 294
  </update>
  <update id="updateByPrimaryKey" parameterType="com.sunyo.wlpt.message.bus.service.domain.UserMessageBinding">
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313
      <!--@mbg.generated-->
      update user_message_binding
      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},
          subscriber        = #{subscriber,jdbcType=VARCHAR},
          description       = #{description,jdbcType=VARCHAR},
          gmt_create        = #{gmtCreate,jdbcType=TIMESTAMP},
          gmt_modified      = #{gmtModified,jdbcType=TIMESTAMP}
      where id = #{id,jdbcType=VARCHAR}
314
  </update>
王勇 authored
315
    <!-- 查询列表,选择性 -->
王勇 authored
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331
    <select id="selectUserMessageBindingList"
            parameterType="com.sunyo.wlpt.message.bus.service.domain.UserMessageBinding" resultMap="BaseResultMap">
        select user_id,
               username,
               server_id,
               `server_name`,
               virtual_host_id,
               virtual_host_name,
               exchange_id,
               exchange_name,
               routing_key_id,
               routing_key_name,
               GROUP_CONCAT(id)          as id,
               GROUP_CONCAT(queue_id)    as queue_id,
               GROUP_CONCAT(queue_name)  as queue_name,
               GROUP_CONCAT(description) as description
王勇 authored
332 333 334
        from user_message_binding
        <where>
            <!-- 所属用户登陆名称 -->
王勇 authored
335
            <if test="username != null and username != ''">
王勇 authored
336 337
                username = #{username,jdbcType=VARCHAR}
            </if>
王勇 authored
338 339
            <!-- 所属服务器名称 -->
            <if test="serverName != null and serverName != ''">
王勇 authored
340 341
                AND `server_name` = #{serverName,jdbcType=VARCHAR}
            </if>
王勇 authored
342
            <!-- 所属虚拟主机名称 -->
王勇 authored
343
            <if test="virtualHostName != null and virtualHostName != ''">
王勇 authored
344 345 346
                AND virtual_host_name = #{virtualHostName,jdbcType=VARCHAR}
            </if>
            <!-- 所属交换机名称 -->
王勇 authored
347
            <if test="exchangeName != null and exchangeName != ''">
王勇 authored
348 349 350
                AND exchange_name = #{exchangeName,jdbcType=VARCHAR}
            </if>
            <!-- 所属队列名称 -->
王勇 authored
351
            <if test="queueName != null and queueName != ''">
王勇 authored
352 353 354
                AND queue_name = #{queueName,jdbcType=VARCHAR}
            </if>
            <!-- 所属路由键名称 -->
王勇 authored
355
            <if test="routingKeyName != null and routingKeyName != ''">
王勇 authored
356 357 358
                AND routing_key_name = #{routingKeyName,jdbcType=VARCHAR}
            </if>
        </where>
王勇 authored
359
        group by user_id, username, server_id, `server_name`, virtual_host_id, virtual_host_name,
王勇 authored
360
                 exchange_id, exchange_name, routing_key_id, routing_key_name
王勇 authored
361
    </select>
王勇 authored
362 363 364 365 366
    <!-- 校验是否已存在 -->
    <select id="validateBinding" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from user_message_binding
367 368
        <where>
            <!-- 所属用户id -->
369 370 371 372 373 374
            <!--            <if test="userId != null and userId != ''">-->
            <!--                user_id = #{userId,jdbcType=VARCHAR}-->
            <!--            </if>-->
            <if test="username != null and username != ''">
                AND username = #{username,jdbcType=VARCHAR}
            </if>
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395
            <!-- 所属服务器id -->
            <if test="serverId != null and serverId != ''">
                AND server_id = #{serverId,jdbcType=VARCHAR}
            </if>
            <!-- 所属虚拟主机id -->
            <if test="virtualHostId != null and virtualHostId != ''">
                AND virtual_host_id = #{virtualHostId,jdbcType=VARCHAR}
            </if>
            <!-- 所属交换机id -->
            <if test="exchangeId != null and exchangeId != ''">
                AND exchange_id = #{exchangeId,jdbcType=VARCHAR}
            </if>
            <!-- 所属队列id -->
            <if test="queueId != null and queueId != ''">
                AND queue_id = #{queueId,jdbcType=VARCHAR}
            </if>
            <!-- 所属路由键id -->
            <if test="routingKeyId != null and routingKeyId != ''">
                AND routing_key_id = #{routingKeyId,jdbcType=VARCHAR}
            </if>
        </where>
王勇 authored
396
    </select>
397 398 399 400 401 402 403
    <select id="validateNote" parameterType="com.sunyo.wlpt.message.bus.service.domain.MessageNote"
            resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from user_message_binding
        <where>
            <!-- 所属用户id -->
404 405
            <if test="username != null and username != ''">
                username = #{username,jdbcType=VARCHAR}
406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427
            </if>
            <!-- 所属服务器id -->
            <if test="serverId != null and serverId != ''">
                AND server_id = #{serverId,jdbcType=VARCHAR}
            </if>
            <!-- 所属虚拟主机id -->
            <if test="virtualHostId != null and virtualHostId != ''">
                AND virtual_host_id = #{virtualHostId,jdbcType=VARCHAR}
            </if>
            <!-- 所属交换机id -->
            <if test="exchangeId != null and exchangeId != ''">
                AND exchange_id = #{exchangeId,jdbcType=VARCHAR}
            </if>
            <!-- 所属路由键id -->
            <if test="routingKeyId != null and routingKeyId != ''">
                AND routing_key_id = #{routingKeyId,jdbcType=VARCHAR}
            </if>
        </where>
    </select>

    <select id="validateXmlBinding" parameterType="com.sunyo.wlpt.message.bus.service.domain.XmlData"
            resultMap="BaseResultMap">
428
        select
429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453
        <include refid="Base_Column_List"/>
        from user_message_binding
        <where>
            <!-- 用户 -->
            <if test="sender != null and sender != ''">
                username = #{sender,jdbcType=VARCHAR}
            </if>
            <!-- 服务器名称 -->
            <if test="serverName != null and serverName != ''">
                AND server_name = #{serverName,jdbcType=VARCHAR}
            </if>
            <!-- 虚拟主机名称 -->
            <if test="virtualHostName != null and virtualHostName != ''">
                AND virtual_host_name = #{virtualHostName,jdbcType=VARCHAR}
            </if>
            <!-- 交换机名称 -->
            <if test="exchangeName != null and exchangeName != ''">
                AND exchange_name = #{exchangeName,jdbcType=VARCHAR}
            </if>
            <!-- 路由键名称 -->
            <if test="routingKeyName != null and routingKeyName != ''">
                AND routing_key_name = #{routingKeyName,jdbcType=VARCHAR}
            </if>
        </where>
    </select>
454 455 456 457 458 459 460 461 462 463 464 465

    <select id="validateRabbitBinding" parameterType="com.sunyo.wlpt.message.bus.service.domain.UserMessageBinding"
            resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from user_message_binding
        <where>
            queue_name = #{queueName,jdbcType=VARCHAR}
                    AND exchange_name = #{exchangeName,jdbcType=VARCHAR}
                    AND routing_key_name = #{routingKeyName,jdbcType=VARCHAR}
        </where>
    </select>
466
</mapper>