BusExchangeMapper.xml
11.6 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
<?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.BusExchangeMapper">
<cache-ref namespace="com.sunyo.wlpt.message.bus.service.mapper.VirtualHostMapper"/>
<resultMap id="BaseResultMap" type="com.sunyo.wlpt.message.bus.service.domain.BusExchange">
<!--@mbg.generated-->
<!--@Table bus_exchange-->
<id column="id" jdbcType="VARCHAR" property="id"/>
<result column="exchange_name" jdbcType="VARCHAR" property="exchangeName"/>
<result column="exchange_name" jdbcType="VARCHAR" property="aliasName"/>
<result column="virtual_host_id" jdbcType="VARCHAR" property="virtualHostId"/>
<result column="exchange_type" jdbcType="VARCHAR" property="exchangeType"/>
<result column="durability" jdbcType="BOOLEAN" property="durability"/>
<result column="auto_delete" jdbcType="BOOLEAN" property="autoDelete"/>
<result column="internal" jdbcType="BOOLEAN" property="internal"/>
<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 id="ExchangeAndHostMap" extends="BaseResultMap"
type="com.sunyo.wlpt.message.bus.service.domain.BusExchange">
<association property="virtualHost" javaType="com.sunyo.wlpt.message.bus.service.domain.VirtualHost">
<id column="id" property="id"/>
<result column="virtual_host_name" property="virtualHostName"/>
</association>
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, exchange_name, virtual_host_id, exchange_type, durability, auto_delete, internal,
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_exchange
where id = #{id,jdbcType=VARCHAR}
</select>
<select id="selectByExchangeName" parameterType="java.lang.String" resultMap="BaseResultMap">
<!--@mbg.generated-->
select
<include refid="Base_Column_List"/>
from bus_exchange
where exchange_name = #{exchangeName,jdbcType=VARCHAR}
</select>
<!-- 获取交换机列表,根据虚拟主机id -->
<select id="selectByVirtualHostId" parameterType="java.lang.String" resultMap="BaseResultMap">
<!--@mbg.generated-->
select
<include refid="Base_Column_List"/>
from bus_exchange
where virtual_host_id = #{virtualHostId,jdbcType=VARCHAR}
</select>
<!-- 获取交换机列表 -->
<select id="selectBusExchangeList" parameterType="com.sunyo.wlpt.message.bus.service.domain.BusExchange"
resultMap="ExchangeAndHostMap">
select e.id,
e.exchange_name,
e.virtual_host_id,
e.exchange_type,
e.durability,
e.auto_delete,
e.internal,
e.arguments,
e.description,
e.gmt_create,
e.gmt_modified,
v.virtual_host_name
from bus_exchange as e,
virtual_host as v
<where>
<!-- 所属虚拟主机ID -->
<if test="virtualHostId != null and virtualHostId != ''">
e.virtual_host_id = #{virtualHostId,jdbcType=VARCHAR}
</if>
<!-- 交换机名称 -->
<if test="exchangeName != null and exchangeName != ''">
and e.exchange_name = #{exchangeName,jdbcType=VARCHAR}
</if>
and e.virtual_host_id = v.id
</where>
</select>
<!-- 校验交换机是否已存在 -->
<select id="validateBusExchange" parameterType="com.sunyo.wlpt.message.bus.service.domain.BusExchange"
resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from bus_exchange
<where>
<!-- 交换机名称 -->
<if test="exchangeName != null and exchangeName != ''">
exchange_name = #{exchangeName,jdbcType=VARCHAR}
</if>
</where>
</select>
<!-- 仅,查询交换机列表 -->
<select id="getExchangeList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from bus_exchange
<where>
<!-- 所属虚拟主机ID -->
<if test="virtualHostId != null and virtualHostId != ''">
virtual_host_id = #{virtualHostId,jdbcType=VARCHAR}
</if>
</where>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
<!--@mbg.generated-->
delete
from bus_exchange
where id = #{id,jdbcType=VARCHAR}
</delete>
<delete id="deleteByVirtualHostId" parameterType="java.lang.String">
<!--@mbg.generated-->
delete
from bus_exchange
where virtual_host_id = #{virtualHostId,jdbcType=VARCHAR}
</delete>
<insert id="insert" parameterType="com.sunyo.wlpt.message.bus.service.domain.BusExchange">
<!--@mbg.generated-->
insert into bus_exchange (id, exchange_name, virtual_host_id,
exchange_type, durability, auto_delete,
internal, arguments, description,
gmt_create, gmt_modified)
values (#{id,jdbcType=VARCHAR}, #{exchangeName,jdbcType=VARCHAR}, #{virtualHostId,jdbcType=VARCHAR},
#{exchangeType,jdbcType=VARCHAR}, #{durability,jdbcType=BOOLEAN}, #{autoDelete,jdbcType=BOOLEAN},
#{internal,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.BusExchange">
<!--@mbg.generated-->
insert into bus_exchange
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="exchangeName != null">
exchange_name,
</if>
<if test="virtualHostId != null">
virtual_host_id,
</if>
<if test="exchangeType != null">
exchange_type,
</if>
<if test="durability != null">
durability,
</if>
<if test="autoDelete != null">
auto_delete,
</if>
<if test="internal != null">
internal,
</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="exchangeName != null">
#{exchangeName,jdbcType=VARCHAR},
</if>
<if test="virtualHostId != null">
#{virtualHostId,jdbcType=VARCHAR},
</if>
<if test="exchangeType != null">
#{exchangeType,jdbcType=VARCHAR},
</if>
<if test="durability != null">
#{durability,jdbcType=BOOLEAN},
</if>
<if test="autoDelete != null">
#{autoDelete,jdbcType=BOOLEAN},
</if>
<if test="internal != null">
#{internal,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.BusExchange">
<!--@mbg.generated-->
update bus_exchange
<set>
<if test="exchangeName != null">
exchange_name = #{exchangeName,jdbcType=VARCHAR},
</if>
<if test="virtualHostId != null">
virtual_host_id = #{virtualHostId,jdbcType=VARCHAR},
</if>
<if test="exchangeType != null">
exchange_type = #{exchangeType,jdbcType=VARCHAR},
</if>
<if test="durability != null">
durability = #{durability,jdbcType=BOOLEAN},
</if>
<if test="autoDelete != null">
auto_delete = #{autoDelete,jdbcType=BOOLEAN},
</if>
<if test="internal != null">
internal = #{internal,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.BusExchange">
<!--@mbg.generated-->
update bus_exchange
set exchange_name = #{exchangeName,jdbcType=VARCHAR},
virtual_host_id = #{virtualHostId,jdbcType=VARCHAR},
exchange_type = #{exchangeType,jdbcType=VARCHAR},
durability = #{durability,jdbcType=BOOLEAN},
auto_delete = #{autoDelete,jdbcType=BOOLEAN},
internal = #{internal,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="selectExchangeExist" parameterType="com.sunyo.wlpt.message.bus.service.domain.BusExchange"
resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from bus_exchange
<where>
<!-- 交换机名称 -->
<if test="exchangeName != null and exchangeName != ''">
exchange_name = #{exchangeName,jdbcType=VARCHAR}
</if>
<!-- 所属虚拟主机ID -->
<if test="virtualHostId != null and virtualHostId != ''">
and virtual_host_id = #{virtualHostId,jdbcType=VARCHAR}
</if>
</where>
</select>
</mapper>