BusQueueMapper.xml 10.3 KB
<?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.BusQueueMapper">
    <cache-ref namespace="com.sunyo.wlpt.message.bus.service.mapper.VirtualHostMapper"/>
    <resultMap id="BaseResultMap" type="com.sunyo.wlpt.message.bus.service.domain.BusQueue">
        <!--@mbg.generated-->
        <!--@Table bus_queue-->
        <id column="id" jdbcType="VARCHAR" property="id"/>
        <result column="queue_name" jdbcType="VARCHAR" property="queueName"/>
        <result column="user_id" jdbcType="VARCHAR" property="userId"/>
        <result column="username" jdbcType="VARCHAR" property="username"/>
        <result column="virtual_host_id" jdbcType="VARCHAR" property="virtualHostId"/>
        <result column="durability" jdbcType="BOOLEAN" property="durability"/>
        <result column="auto_delete" jdbcType="BOOLEAN" property="autoDelete"/>
        <result column="arguments" jdbcType="VARCHAR" property="arguments"/>
        <result column="description" jdbcType="VARCHAR" property="description"/>
        <result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate"/>
        <result column="gmt_modified" jdbcType="TIMESTAMP" property="gmtModified"/>
    </resultMap>

    <!-- 该Mapper映射关系的作用,是队列与虚拟主机的1:1的关系映射 -->
    <resultMap extends="BaseResultMap" id="QueueAndHostMap" type="com.sunyo.wlpt.message.bus.service.domain.BusQueue">
        <association javaType="com.sunyo.wlpt.message.bus.service.domain.VirtualHost" property="virtualHost">
            <id column="id" property="id"/>
            <result column="virtual_host_name" property="virtualHostName"/>
        </association>
    </resultMap>

  <sql id="Base_Column_List">
      <!--@mbg.generated-->
      id, queue_name, user_id, username, virtual_host_id, durability, auto_delete, arguments,
    description, gmt_create, gmt_modified
  </sql>

  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
      <!--@mbg.generated-->
      select
      <include refid="Base_Column_List"/>
      from bus_queue
      where id = #{id,jdbcType=VARCHAR}
  </select>

  <select id="selectByVirtualHostId" parameterType="java.lang.String" resultMap="BaseResultMap">
      select
      <include refid="Base_Column_List"/>
      from bus_queue
      where virtual_host_id = #{virtualHostId,jdbcType=VARCHAR}
  </select>

  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
      <!--@mbg.generated-->
      delete
      from bus_queue
      where id = #{id,jdbcType=VARCHAR}
  </delete>

  <delete id="deleteByVirtualHostId" parameterType="java.lang.String">
      <!--@mbg.generated-->
      delete
      from bus_queue
      where virtual_host_id = #{virtualHostId,jdbcType=VARCHAR}
  </delete>

  <insert id="insert" parameterType="com.sunyo.wlpt.message.bus.service.domain.BusQueue">
      <!--@mbg.generated-->
      insert into bus_queue (id, queue_name, user_id,
                             username, virtual_host_id, durability,
                             auto_delete, arguments, description,
                             gmt_create, gmt_modified)
      values (#{id,jdbcType=VARCHAR}, #{queueName,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR},
              #{username,jdbcType=VARCHAR}, #{virtualHostId,jdbcType=VARCHAR}, #{durability,jdbcType=BOOLEAN},
              #{autoDelete,jdbcType=BOOLEAN}, #{arguments,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR},
              #{gmtCreate,jdbcType=TIMESTAMP}, #{gmtModified,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" parameterType="com.sunyo.wlpt.message.bus.service.domain.BusQueue">
      <!--@mbg.generated-->
      insert into bus_queue
      <trim prefix="(" suffix=")" suffixOverrides=",">
          <if test="id != null">
              id,
          </if>
      <if test="queueName != null">
          queue_name,
      </if>
      <if test="userId != null">
          user_id,
      </if>
      <if test="username != null">
          username,
      </if>
      <if test="virtualHostId != null">
          virtual_host_id,
      </if>
      <if test="durability != null">
          durability,
      </if>
      <if test="autoDelete != null">
          auto_delete,
      </if>
      <if test="arguments != null">
          arguments,
      </if>
      <if test="description != null">
          description,
      </if>
      <if test="gmtCreate != null">
          gmt_create,
      </if>
      <if test="gmtModified != null">
          gmt_modified,
      </if>
      </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
        <if test="id != null">
            #{id,jdbcType=VARCHAR},
        </if>
      <if test="queueName != null">
          #{queueName,jdbcType=VARCHAR},
      </if>
      <if test="userId != null">
          #{userId,jdbcType=VARCHAR},
      </if>
      <if test="username != null">
          #{username,jdbcType=VARCHAR},
      </if>
      <if test="virtualHostId != null">
          #{virtualHostId,jdbcType=VARCHAR},
      </if>
      <if test="durability != null">
          #{durability,jdbcType=BOOLEAN},
      </if>
      <if test="autoDelete != null">
          #{autoDelete,jdbcType=BOOLEAN},
      </if>
      <if test="arguments != null">
          #{arguments,jdbcType=VARCHAR},
      </if>
      <if test="description != null">
          #{description,jdbcType=VARCHAR},
      </if>
      <if test="gmtCreate != null">
          #{gmtCreate,jdbcType=TIMESTAMP},
      </if>
      <if test="gmtModified != null">
          #{gmtModified,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.sunyo.wlpt.message.bus.service.domain.BusQueue">
      <!--@mbg.generated-->
      update bus_queue
      <set>
          <if test="queueName != null">
              queue_name = #{queueName,jdbcType=VARCHAR},
          </if>
          <if test="userId != null">
              user_id = #{userId,jdbcType=VARCHAR},
          </if>
          <if test="username != null">
              username = #{username,jdbcType=VARCHAR},
          </if>
          <if test="virtualHostId != null">
              virtual_host_id = #{virtualHostId,jdbcType=VARCHAR},
          </if>
          <if test="durability != null">
              durability = #{durability,jdbcType=BOOLEAN},
          </if>
          <if test="autoDelete != null">
              auto_delete = #{autoDelete,jdbcType=BOOLEAN},
          </if>
          <if test="arguments != null">
              arguments = #{arguments,jdbcType=VARCHAR},
          </if>
          <if test="description != null">
              description = #{description,jdbcType=VARCHAR},
          </if>
          <if test="gmtCreate != null">
              gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
          </if>
          <if test="gmtModified != null">
              gmt_modified = #{gmtModified,jdbcType=TIMESTAMP},
          </if>
      </set>
      where id = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.sunyo.wlpt.message.bus.service.domain.BusQueue">
      <!--@mbg.generated-->
      update bus_queue
      set queue_name      = #{queueName,jdbcType=VARCHAR},
          user_id         = #{userId,jdbcType=VARCHAR},
          username        = #{username,jdbcType=VARCHAR},
          virtual_host_id = #{virtualHostId,jdbcType=VARCHAR},
          durability      = #{durability,jdbcType=BOOLEAN},
          auto_delete     = #{autoDelete,jdbcType=BOOLEAN},
          arguments       = #{arguments,jdbcType=VARCHAR},
          description     = #{description,jdbcType=VARCHAR},
          gmt_create      = #{gmtCreate,jdbcType=TIMESTAMP},
          gmt_modified    = #{gmtModified,jdbcType=TIMESTAMP}
      where id = #{id,jdbcType=VARCHAR}
  </update>

    <!-- 获取消息队列,列表 -->
    <select id="selectBusQueueList" parameterType="com.sunyo.wlpt.message.bus.service.domain.BusQueue"
            resultMap="QueueAndHostMap">
        select q.id,
               q.queue_name,
               q.virtual_host_id,
               q.durability,
               q.auto_delete,
               q.arguments,
               q.description,
               q.user_id,
               q.username,
               q.gmt_create,
               q.gmt_modified,
               v.virtual_host_name
        from bus_queue as q,
             virtual_host v
        <where>
            <!-- 所属虚拟主机Id -->
            <if test="virtualHostId != null and virtualHostId != ''">
                virtual_host_id = #{virtualHostId,jdbcType=VARCHAR}
            </if>
            <!-- 用户名称 -->
            <if test="username != null and username != ''">
                and username = #{username,jdbcType=VARCHAR}
            </if>
            <!-- 消息队列名称 -->
            <if test="queueName != null and queueName != ''">
                and queue_name = #{queueName,jdbcType=VARCHAR}
            </if>
            and v.id = q.virtual_host_id
        </where>
    </select>

    <!-- 校验消息队列是否已存在-->
    <select id="validateBusQueue" parameterType="com.sunyo.wlpt.message.bus.service.domain.BusQueue"
            resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from bus_queue
        <where>
            <!-- 消息队列名称 -->
            <if test="queueName != null and queueName != ''">
                queue_name = #{queueName,jdbcType=VARCHAR}
            </if>
        </where>
    </select>

    <!-- 仅,查询队列列表 -->
    <select id="getQueueList" parameterType="com.sunyo.wlpt.message.bus.service.domain.BusQueue"
            resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from bus_queue
        <where>
            <!-- 所属虚拟主机Id -->
            <if test="virtualHostId != null and virtualHostId != ''">
                virtual_host_id = #{virtualHostId,jdbcType=VARCHAR}
            </if>
            <if test="username != null and username != ''">
                and username = #{username,jdbcType=VARCHAR}
            </if>
        </where>
    </select>

    <select id="selectByUsername" parameterType="java.lang.String" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from bus_queue
        where username = #{username,jdbcType=VARCHAR}
    </select>
</mapper>