AddressMapperAuto.xml
5.33 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
<?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.huaheng.pc.config.address.mapper.AddressMapperAuto">
<select id="selectListEntityByLike" resultType="com.huaheng.pc.config.address.domain.Address">
SELECT id, warehouseCode, param, url
FROM address
<where>
<if test="id != null ">
AND id = #{id}
</if>
<if test="warehouseCode != null and warehouseCode != '' ">
AND warehouseCode = #{warehouseCode}
</if>
<if test="param != null and param != ''">
<bind name="paramPattern" value="'%' + param + '%'" />
AND param like #{paramPattern}
</if>
<if test="url != null and url != ''">
<bind name="urlPattern" value="'%' + url + '%'" />
AND url like #{urlPattern}
</if>
</where>
</select>
<select id="selectListEntityByEqual" resultType="com.huaheng.pc.config.address.domain.Address">
SELECT id, warehouseCode, param, url
FROM address
<where>
<if test="id != null">
AND id = #{id}
</if>
<if test="warehouseCode != null">
AND warehouseCode = #{warehouseCode}
</if>
<if test="param != null">
AND param = #{param}
</if>
<if test="url != null">
AND url = #{url}
</if>
</where>
</select>
<select id="selectListMapByEqual" resultType="java.util.HashMap">
SELECT ${columns} FROM address
<where>
<if test="condition.id != null">
AND id = #{condition.id}
</if>
<if test="condition.warehouseCode != null">
AND warehouseCode = #{condition.warehouseCode}
</if>
<if test="condition.param != null">
AND param = #{condition.param}
</if>
<if test="condition.url != null">
AND url = #{condition.url}
</if>
</where>
</select>
<select id="selectEntityById" resultType="com.huaheng.pc.config.address.domain.Address">
SELECT id, warehouseCode, param, url FROM address WHERE id = #{id}
</select>
<select id="selectFirstEntity" resultType="com.huaheng.pc.config.address.domain.Address">
SELECT id, warehouseCode, param, url
FROM address
<where>
<if test="id != null">
AND id = #{id}
</if>
<if test="warehouseCode != null">
AND warehouseCode = #{warehouseCode}
</if>
<if test="param != null">
AND param = #{param}
</if>
<if test="url != null">
AND url = #{url}
</if>
</where>
LIMIT 1
</select>
<select id="selectFirstMap" resultType="java.util.HashMap">
SELECT ${columns} FROM address
<where>
<if test="condition.id != null">
AND id = #{condition.id}
</if>
<if test="condition.warehouseCode != null">
AND warehouseCode = #{condition.warehouseCode}
</if>
<if test="condition.param != null">
AND param = #{condition.param}
</if>
<if test="condition.url != null">
AND url = #{condition.url}
</if>
</where>
LIMIT 1
</select>
<insert id="insert" parameterType="com.huaheng.pc.config.address.domain.Address" keyProperty="id" useGeneratedKeys="true" >
INSERT INTO address
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="warehouseCode != null">
warehouseCode,
</if>
<if test="param != null">
param,
</if>
<if test="url != null">
url,
</if>
</trim>
<trim prefix=" values (" suffix=")" suffixOverrides=",">
<if test="warehouseCode != null">
#{warehouseCode, jdbcType=VARCHAR},
</if>
<if test="param != null">
#{param, jdbcType=VARCHAR},
</if>
<if test="url != null">
#{url, jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByModel">
UPDATE address
<set>
<if test="warehouseCode != null">
warehouseCode = #{warehouseCode, jdbcType=VARCHAR},
</if>
<if test="param != null">
param = #{param, jdbcType=VARCHAR},
</if>
<if test="url != null">
url = #{url, jdbcType=VARCHAR},
</if>
</set>
WHERE id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByCondition">
UPDATE address
<set>
<if test="record.warehouseCode != null">
warehouseCode = #{record.warehouseCode, jdbcType=VARCHAR},
</if>
<if test="record.param != null">
param = #{record.param, jdbcType=VARCHAR},
</if>
<if test="record.url != null">
url = #{record.url, jdbcType=VARCHAR},
</if>
</set>
<where>
<if test="condition.id != null">
AND id = #{condition.id}
</if>
<if test="condition.warehouseCode != null">
AND warehouseCode = #{condition.warehouseCode}
</if>
<if test="condition.param != null">
AND param = #{condition.param}
</if>
<if test="condition.url != null">
AND url = #{condition.url}
</if>
</where>
</update>
<delete id="deleteById">
DELETE FROM address WHERE id = #{id, jdbcType=INTEGER}
</delete>
<delete id="deleteByCondition">
DELETE FROM address
<where>
<if test="id != null">
AND id = #{id}
</if>
<if test="warehouseCode != null">
AND warehouseCode = #{warehouseCode}
</if>
<if test="param != null">
AND param = #{param}
</if>
<if test="url != null">
AND url = #{url}
</if>
</where>
</delete>
</mapper>