审查视图

src/main/resources/mapper/VirtualHostMapper.xml 9.6 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.VirtualHostMapper">
4
    <cache type="com.sunyo.wlpt.message.bus.service.cache.RedisCache"/>
王勇 authored
5 6 7 8 9 10 11 12 13 14
    <resultMap id="BaseResultMap" type="com.sunyo.wlpt.message.bus.service.domain.VirtualHost">
        <!--@mbg.generated-->
        <!--@Table virtual_host-->
        <id column="id" jdbcType="VARCHAR" property="id"/>
        <result column="virtual_host_name" jdbcType="VARCHAR" property="virtualHostName"/>
        <result column="server_id" jdbcType="VARCHAR" property="serverId"/>
        <result column="description" jdbcType="VARCHAR" property="description"/>
        <result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate"/>
        <result column="gmt_modified" jdbcType="TIMESTAMP" property="gmtModified"/>
    </resultMap>
王勇 authored
15 16
    <!-- 该Mapper映射关系的作用,是虚拟主机与服务器的1:1的关系映射 -->
    <resultMap id="HostAndServerMap" extends="BaseResultMap"
王勇 authored
17 18
               type="com.sunyo.wlpt.message.bus.service.domain.VirtualHost">
        <association property="busServer" javaType="com.sunyo.wlpt.message.bus.service.domain.BusServer">
王勇 authored
19 20
            <id column="id" property="id"/>
            <result column="server_name" property="serverName"/>
王勇 authored
21 22 23
        </association>
    </resultMap>
王勇 authored
24 25 26 27 28 29 30 31 32 33 34
    <sql id="Base_Column_List">
        <!--@mbg.generated-->
        id, virtual_host_name, server_id, description, gmt_create, gmt_modified
    </sql>
    <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
        <!--@mbg.generated-->
        select
        <include refid="Base_Column_List"/>
        from virtual_host
        where id = #{id,jdbcType=VARCHAR}
    </select>
35
36 37 38 39 40 41 42 43
    <select id="selectByVirtualHostName" parameterType="java.lang.String" resultMap="BaseResultMap">
        <!--@mbg.generated-->
        select
        <include refid="Base_Column_List"/>
        from virtual_host
        where virtual_host_name = #{virtualHostName,jdbcType=VARCHAR}
    </select>
44 45 46 47 48 49 50 51 52
    <!--  根据服务器id,查询虚拟主机列表  -->
    <select id="selectByServerId" parameterType="java.lang.String" resultMap="BaseResultMap">
        <!--@mbg.generated-->
        select
        <include refid="Base_Column_List"/>
        from virtual_host
        where server_id = #{serverId,jdbcType=VARCHAR}
    </select>
王勇 authored
53
    <!--  查询虚拟主机列表,选择性  -->
王勇 authored
54
    <select id="selectVirtualHostList" parameterType="com.sunyo.wlpt.message.bus.service.domain.VirtualHost"
王勇 authored
55
            resultMap="HostAndServerMap">
王勇 authored
56 57 58 59 60 61 62 63 64
        select v.id,
               v.virtual_host_name,
               v.server_id,
               v.description,
               v.gmt_create,
               v.gmt_modified,
               s.server_name
        from virtual_host as v,
             bus_server as s
王勇 authored
65 66
        <where>
            <!-- 所属服务器ID -->
王勇 authored
67
            <if test="serverId != null and serverId != ''">
王勇 authored
68
                v.server_id = #{serverId,jdbcType=VARCHAR}
王勇 authored
69 70
            </if>
            <!-- 虚拟主机名称 -->
王勇 authored
71
            <if test="virtualHostName != null and virtualHostName != ''">
王勇 authored
72
                and v.virtual_host_name = #{virtualHostName,jdbcType=VARCHAR}
王勇 authored
73
            </if>
王勇 authored
74
            and v.server_id = s.id
王勇 authored
75 76 77
        </where>
    </select>
王勇 authored
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96

    <!--  查询虚拟主机列表,选择性  -->
    <!--    <select id="selectVirtualHostList" parameterType="com.sunyo.wlpt.message.bus.service.domain.VirtualHost"-->
    <!--            resultMap="BaseResultMap">-->
    <!--        select-->
    <!--        <include refid="Base_Column_List"/>-->
    <!--        from virtual_host-->
    <!--        <where>-->
    <!--            &lt;!&ndash; 所属服务器ID &ndash;&gt;-->
    <!--            <if test="serverId != null and serverId !=''">-->
    <!--                server_id = #{serverId,jdbcType=VARCHAR}-->
    <!--            </if>-->
    <!--            &lt;!&ndash; 虚拟主机名称 &ndash;&gt;-->
    <!--            <if test="virtualHostName != null and virtualHostName !=''">-->
    <!--               and virtual_host_name = #{virtualHostName,jdbcType=VARCHAR}-->
    <!--            </if>-->
    <!--        </where>-->
    <!--    </select>-->
王勇 authored
97 98 99 100 101 102 103 104
    <!-- 校验虚拟主机信息是否存在 -->
    <select id="validateVirtualHost" parameterType="com.sunyo.wlpt.message.bus.service.domain.VirtualHost"
            resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from virtual_host
        <where>
            <!-- 虚拟主机名称 -->
王勇 authored
105
            <if test="virtualHostName != null and virtualHostName != ''">
王勇 authored
106 107 108 109
                virtual_host_name = #{virtualHostName,jdbcType=VARCHAR}
            </if>
        </where>
    </select>
王勇 authored
110
    <!-- 查询全部虚拟主机列表 -->
王勇 authored
111
    <select id="getVirtualHostList" resultMap="BaseResultMap">
王勇 authored
112 113 114
        select
        <include refid="Base_Column_List"/>
        from virtual_host
115 116
        <where>
            <!-- 所属服务器ID -->
王勇 authored
117
            <if test="serverId != null and serverId != ''">
118 119 120
                server_id = #{serverId,jdbcType=VARCHAR}
            </if>
        </where>
王勇 authored
121
    </select>
王勇 authored
122 123 124

    <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
        <!--@mbg.generated-->
王勇 authored
125 126
        delete
        from virtual_host
王勇 authored
127 128
        where id = #{id,jdbcType=VARCHAR}
    </delete>
129 130 131 132 133

    <delete id="deleteByServerId" parameterType="java.lang.String">
        <!--@mbg.generated-->
        delete
        from virtual_host
134
        where server_id = #{serverId,jdbcType=VARCHAR}
135 136
    </delete>
王勇 authored
137 138 139
    <insert id="insert" parameterType="com.sunyo.wlpt.message.bus.service.domain.VirtualHost">
        <!--@mbg.generated-->
        insert into virtual_host (id, virtual_host_name, server_id,
王勇 authored
140
                                  description, gmt_create, gmt_modified)
王勇 authored
141
        values (#{id,jdbcType=VARCHAR}, #{virtualHostName,jdbcType=VARCHAR}, #{serverId,jdbcType=VARCHAR},
王勇 authored
142
                #{description,jdbcType=VARCHAR}, #{gmtCreate,jdbcType=TIMESTAMP}, #{gmtModified,jdbcType=TIMESTAMP})
王勇 authored
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
    </insert>
    <insert id="insertSelective" parameterType="com.sunyo.wlpt.message.bus.service.domain.VirtualHost">
        <!--@mbg.generated-->
        insert into virtual_host
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="virtualHostName != null">
                virtual_host_name,
            </if>
            <if test="serverId != null">
                server_id,
            </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="virtualHostName != null">
                #{virtualHostName,jdbcType=VARCHAR},
            </if>
            <if test="serverId != null">
                #{serverId,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.VirtualHost">
        <!--@mbg.generated-->
        update virtual_host
        <set>
            <if test="virtualHostName != null">
                virtual_host_name = #{virtualHostName,jdbcType=VARCHAR},
            </if>
            <if test="serverId != null">
                server_id = #{serverId,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.VirtualHost">
        <!--@mbg.generated-->
        update virtual_host
        set virtual_host_name = #{virtualHostName,jdbcType=VARCHAR},
王勇 authored
214 215 216 217
            server_id         = #{serverId,jdbcType=VARCHAR},
            description       = #{description,jdbcType=VARCHAR},
            gmt_create        = #{gmtCreate,jdbcType=TIMESTAMP},
            gmt_modified      = #{gmtModified,jdbcType=TIMESTAMP}
王勇 authored
218 219
        where id = #{id,jdbcType=VARCHAR}
    </update>
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236

    <select id="selectVirtualHostExist" parameterType="com.sunyo.wlpt.message.bus.service.domain.VirtualHost"
            resultMap="HostAndServerMap">
        select
        <include refid="Base_Column_List"/>
        from virtual_host
        <where>
            <!-- 所属服务器ID -->
            <if test="serverId != null and serverId != ''">
                server_id = #{serverId,jdbcType=VARCHAR}
            </if>
            <!-- 虚拟主机名称 -->
            <if test="virtualHostName != null and virtualHostName != ''">
                and  virtual_host_name = #{virtualHostName,jdbcType=VARCHAR}
            </if>
        </where>
    </select>
王勇 authored
237
</mapper>