BusServerMapper.xml
11.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
<?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.BusServerMapper">
<cache-ref namespace="com.sunyo.wlpt.message.bus.service.mapper.VirtualHostMapper"/>
<resultMap id="BaseResultMap" type="com.sunyo.wlpt.message.bus.service.domain.BusServer">
<!--@mbg.generated-->
<!--@Table bus_server-->
<id column="id" jdbcType="VARCHAR" property="id"/>
<result column="server_name" jdbcType="VARCHAR" property="serverName"/>
<result column="server_name" jdbcType="VARCHAR" property="aliasName"/>
<result column="server_ip" jdbcType="VARCHAR" property="serverIp"/>
<result column="server_port" jdbcType="INTEGER" property="serverPort"/>
<result column="client_port" jdbcType="INTEGER" property="clientPort"/>
<result column="super_username" jdbcType="VARCHAR" property="superUsername"/>
<result column="super_password" jdbcType="VARCHAR" property="superPassword"/>
<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:n的关系映射 -->
<resultMap extends="BaseResultMap" id="ServerAndVirtualHostMap"
type="com.sunyo.wlpt.message.bus.service.domain.BusServer">
<collection ofType="com.sunyo.wlpt.message.bus.service.domain.VirtualHost" property="aliasList">
<id column="vid" jdbcType="VARCHAR" property="id"/>
<result column="virtual_host_name" jdbcType="VARCHAR" property="virtualHostName"/>
<result column="virtual_host_name" jdbcType="VARCHAR" property="aliasName"/>
<result column="server_id" jdbcType="VARCHAR" property="serverId"/>
</collection>
</resultMap>
<!-- 该Mapper映射关系的作用,服务器:虚拟主机—>1:n ; 虚拟主机:交换机—>1:n 的关系映射 -->
<resultMap extends="BaseResultMap" id="ServerAndHostAndExchangeMap"
type="com.sunyo.wlpt.message.bus.service.domain.BusServer">
<collection ofType="com.sunyo.wlpt.message.bus.service.domain.VirtualHost" property="aliasList">
<id column="vid" jdbcType="VARCHAR" property="id"/>
<result column="virtual_host_name" jdbcType="VARCHAR" property="virtualHostName"/>
<result column="virtual_host_name" jdbcType="VARCHAR" property="aliasName"/>
<collection ofType="com.sunyo.wlpt.message.bus.service.domain.BusExchange" property="aliasList">
<id column="eid" jdbcType="VARCHAR" property="id"/>
<result column="exchange_name" jdbcType="VARCHAR" property="exchangeName"/>
<result column="exchange_name" jdbcType="VARCHAR" property="aliasName"/>
</collection>
</collection>
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, `server_name`, server_ip, server_port, client_port, super_username, super_password,
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_server
where id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
<!--@mbg.generated-->
delete
from bus_server
where id = #{id,jdbcType=VARCHAR}
</delete>
<insert id="insert" parameterType="com.sunyo.wlpt.message.bus.service.domain.BusServer">
<!--@mbg.generated-->
insert into bus_server (id, `server_name`, server_ip,
server_port, client_port, super_username,
super_password, description, gmt_create,
gmt_modified)
values (#{id,jdbcType=VARCHAR}, #{serverName,jdbcType=VARCHAR}, #{serverIp,jdbcType=VARCHAR},
#{serverPort,jdbcType=INTEGER}, #{clientPort,jdbcType=INTEGER}, #{superUsername,jdbcType=VARCHAR},
#{superPassword,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{gmtCreate,jdbcType=TIMESTAMP},
#{gmtModified,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.sunyo.wlpt.message.bus.service.domain.BusServer">
<!--@mbg.generated-->
insert into bus_server
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="serverName != null">
`server_name`,
</if>
<if test="serverIp != null">
server_ip,
</if>
<if test="serverPort != null">
server_port,
</if>
<if test="clientPort != null">
client_port,
</if>
<if test="superUsername != null">
super_username,
</if>
<if test="superPassword != null">
super_password,
</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="serverName != null">
#{serverName,jdbcType=VARCHAR},
</if>
<if test="serverIp != null">
#{serverIp,jdbcType=VARCHAR},
</if>
<if test="serverPort != null">
#{serverPort,jdbcType=INTEGER},
</if>
<if test="clientPort != null">
#{clientPort,jdbcType=INTEGER},
</if>
<if test="superUsername != null">
#{superUsername,jdbcType=VARCHAR},
</if>
<if test="superPassword != null">
#{superPassword,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.BusServer">
<!--@mbg.generated-->
update bus_server
<set>
<if test="serverName != null">
`server_name` = #{serverName,jdbcType=VARCHAR},
</if>
<if test="serverIp != null">
server_ip = #{serverIp,jdbcType=VARCHAR},
</if>
<if test="serverPort != null">
server_port = #{serverPort,jdbcType=INTEGER},
</if>
<if test="clientPort != null">
client_port = #{clientPort,jdbcType=INTEGER},
</if>
<if test="superUsername != null">
super_username = #{superUsername,jdbcType=VARCHAR},
</if>
<if test="superPassword != null">
super_password = #{superPassword,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.BusServer">
<!--@mbg.generated-->
update bus_server
set `server_name` = #{serverName,jdbcType=VARCHAR},
server_ip = #{serverIp,jdbcType=VARCHAR},
server_port = #{serverPort,jdbcType=INTEGER},
client_port = #{clientPort,jdbcType=INTEGER},
super_username = #{superUsername,jdbcType=VARCHAR},
super_password = #{superPassword,jdbcType=VARCHAR},
description = #{description,jdbcType=VARCHAR},
gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=VARCHAR}
</update>
<!-- 获取服务器列表,可能要级联或者懒加载 -->
<select id="getServerList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from bus_server
</select>
<!-- 查询服务器和虚拟主机基本信息(id,名称) -->
<select id="getServerAndHostList" resultMap="ServerAndVirtualHostMap">
select s.id,
s.server_name,
v.id as vid,
v.virtual_host_name,
v.server_id
from bus_server as s,
virtual_host as v
where s.id = v.server_id
</select>
<!-- 查询服务器和虚拟主机以及虚拟机基本信息(id,名称) -->
<select id="getServerAndHostAndExchangeList" resultMap="ServerAndHostAndExchangeMap">
select s.id,
s.server_name,
v.id as vid,
v.virtual_host_name,
e.id as eid,
e.exchange_name
from bus_server as s,
virtual_host as v,
bus_exchange as e
where s.id = v.server_id
and v.id = e.virtual_host_id
</select>
<!-- 获取服务器列表,分页 -->
<select id="selectBusServerList" parameterType="com.sunyo.wlpt.message.bus.service.domain.BusServer"
resultMap="BaseResultMap">
select id,
`server_name`,
server_ip,
server_port,
client_port,
super_username,
description,
gmt_create,
gmt_modified
from bus_server
<where>
<!-- 服务器名称 -->
<if test="serverName != null and serverName != ''">
server_name = #{serverName,jdbcType=VARCHAR}
</if>
</where>
</select>
<!-- 首先。校验服务器名称,是否存在 -->
<select id="validateServerName" parameterType="com.sunyo.wlpt.message.bus.service.domain.BusServer"
resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from bus_server
<where>
<!-- 服务器名称 -->
<if test="serverName != null and serverName != ''">
server_name = #{serverName,jdbcType=VARCHAR}
</if>
</where>
</select>
<!-- 再校验服务器信息(服务器的ip,服务器的port)是否同时存在 -->
<select id="validateBusServer" parameterType="com.sunyo.wlpt.message.bus.service.domain.BusServer"
resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from bus_server
<where>
<!-- 服务器的ip -->
<if test="serverIp != null and serverIp != ''">
server_ip = #{serverIp,jdbcType=VARCHAR}
</if>
<!-- 服务器的port -->
<if test="serverPort != null and serverPort != ''">
AND server_port = #{serverPort,jdbcType=INTEGER}
</if>
</where>
</select>
<select id="selectByServerName" parameterType="java.lang.String" resultMap="BaseResultMap">
<!--@mbg.generated-->
select
<include refid="Base_Column_List"/>
from bus_server
where server_name = #{serverName,jdbcType=VARCHAR}
</select>
<select id="selectServerExist" parameterType="java.lang.String" resultMap="BaseResultMap">
<!--@mbg.generated-->
select
<include refid="Base_Column_List"/>
from bus_server
where server_name = #{serverName,jdbcType=VARCHAR}
</select>
</mapper>