SpecialActivityMapper.xml
9.93 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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
<?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.yohobuy.platform.dal.event.SpecialActivityMapper">
<resultMap id="BaseResultMap" type="com.yohobuy.platform.dal.event.model.SpecialActivity">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="sort" jdbcType="CHAR" property="sort" />
<result column="title" jdbcType="VARCHAR" property="title" />
<result column="plateform" jdbcType="CHAR" property="plateform" />
<result column="promotion_name" jdbcType="VARCHAR" property="promotionName" />
<result column="create_time" jdbcType="INTEGER" property="createTime" />
<result column="start_time" jdbcType="INTEGER" property="startTime" />
<result column="end_time" jdbcType="INTEGER" property="endTime" />
<result column="logo_url" jdbcType="VARCHAR" property="logoUrl" />
<result column="cover_url" jdbcType="VARCHAR" property="coverUrl" />
<result column="web_url" jdbcType="VARCHAR" property="webUrl" />
<result column="product_pool_id" jdbcType="INTEGER" property="productPoolId" />
<result column="yh_channel" jdbcType="VARCHAR" property="yhChannel" />
<result column="order_num" jdbcType="INTEGER" property="orderNum" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="web_cover_url" jdbcType="VARCHAR" property="webCoverUrl" />
<result column="is_show" jdbcType="CHAR" property="isShow"/>
</resultMap>
<sql id="Base_Column_List">
id,
sort,
title,
plateform,
promotion_name,
create_time,
yh_channel,
start_time,
end_time,
logo_url,
cover_url,
web_url,
product_pool_id,
order_num,
web_cover_url,
CASE
WHEN start_time IS NULL
AND end_time IS NULL THEN
1
WHEN start_time > UNIX_TIMESTAMP() THEN
2
WHEN start_time < UNIX_TIMESTAMP()
AND end_time > UNIX_TIMESTAMP() THEN
3
WHEN end_time < UNIX_TIMESTAMP() THEN
4
END AS STATUS,
is_show
</sql>
<sql id="where">
where 1=1
<if test="plateform != null">
and plateform like '%${plateform}%'
</if>
<if test="sort != null">
and sort=#{sort,jdbcType=VARCHAR}
</if>
<if test="isShow != null">
and is_show=#{isShow,jdbcType=VARCHAR}
</if>
<if test="status !=null">
<if test="status ==1">
and start_time is null and end_time is null
</if>
<if test="status ==2 ">
and start_time > UNIX_TIMESTAMP()
</if>
<if test="status ==3">
and start_time < UNIX_TIMESTAMP() and end_time >UNIX_TIMESTAMP()
</if>
<if test="status ==4">
and end_time < UNIX_TIMESTAMP()
</if>
</if>
<if test="startTime !=null">
and start_time >=#{startTime}
</if>
<if test="endTime !=null">
and end_time <=#{endTime}
</if>
<if test="title !=null">
and title like CONCAT('%',#{title},'%')
</if>
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from special_activity
where id = #{id,jdbcType=INTEGER}
</select>
<select id="querySpecialActivityList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from special_activity
<include refid="where"/>
order by order_num desc ,create_time desc
limit #{offset,jdbcType=INTEGER},#{pageSize,jdbcType=INTEGER}
</select>
<select id="querySpecialActivityCount" resultType="long">
select count(1)
from special_activity
<include refid="where"/>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from special_activity
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.yohobuy.platform.dal.event.model.SpecialActivity">
insert into special_activity (id, sort, title,
plateform, promotion_name, create_time,
start_time, end_time, logo_url,
cover_url, web_url, product_pool_id,order_num,web_cover_url
)
values (#{id,jdbcType=INTEGER}, #{sort,jdbcType=CHAR}, #{title,jdbcType=VARCHAR},
#{plateform,jdbcType=CHAR}, #{promotionName,jdbcType=VARCHAR}, #{createTime,jdbcType=INTEGER},
#{startTime,jdbcType=INTEGER}, #{endTime,jdbcType=INTEGER}, #{logoUrl,jdbcType=VARCHAR},
#{coverUrl,jdbcType=VARCHAR}, #{webUrl,jdbcType=VARCHAR}, #{productPoolId,jdbcType=INTEGER}, #{orderNum,jdbcType=INTEGER},
#{webCoverUrl,jdbcType=VARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="com.yohobuy.platform.dal.event.model.SpecialActivity">
insert into special_activity
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="sort != null">
sort,
</if>
<if test="title != null">
title,
</if>
<if test="plateform != null">
plateform,
</if>
<if test="promotionName != null">
promotion_name,
</if>
create_time,
<if test="startTime != null">
start_time,
</if>
<if test="endTime != null">
end_time,
</if>
<if test="logoUrl != null">
logo_url,
</if>
<if test="coverUrl != null">
cover_url,
</if>
<if test="webUrl != null">
web_url,
</if>
<if test="productPoolId != null">
product_pool_id,
</if>
<if test="orderNum != null">
order_num,
</if>
<if test="yhChannel != null">
yh_channel,
</if>
<if test="webCoverUrl != null">
web_cover_url,
</if>
<if test="isShow != null">
is_show,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="sort != null">
#{sort,jdbcType=CHAR},
</if>
<if test="title != null">
#{title,jdbcType=VARCHAR},
</if>
<if test="plateform != null">
#{plateform,jdbcType=CHAR},
</if>
<if test="promotionName != null">
#{promotionName,jdbcType=VARCHAR},
</if>
UNIX_TIMESTAMP(),
<if test="startTime != null">
#{startTime,jdbcType=INTEGER},
</if>
<if test="endTime != null">
#{endTime,jdbcType=INTEGER},
</if>
<if test="logoUrl != null">
#{logoUrl,jdbcType=VARCHAR},
</if>
<if test="coverUrl != null">
#{coverUrl,jdbcType=VARCHAR},
</if>
<if test="webUrl != null">
#{webUrl,jdbcType=VARCHAR},
</if>
<if test="productPoolId != null">
#{productPoolId,jdbcType=INTEGER},
</if>
<if test="orderNum != null">
#{orderNum,jdbcType=INTEGER},
</if>
<if test="yhChannel != null">
#{yhChannel,jdbcType=VARCHAR},
</if>
<if test="webCoverUrl != null">
#{webCoverUrl,jdbcType=VARCHAR},
</if>
<if test="isShow != null">
#{isShow,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yohobuy.platform.dal.event.model.SpecialActivity">
update special_activity
<set>
<if test="sort != null">
sort = #{sort,jdbcType=CHAR},
</if>
<if test="title != null">
title = #{title,jdbcType=VARCHAR},
</if>
<if test="plateform != null">
plateform = #{plateform,jdbcType=CHAR},
</if>
<if test="promotionName != null">
promotion_name = #{promotionName,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=INTEGER},
</if>
<if test="startTime != null">
start_time = #{startTime,jdbcType=INTEGER},
</if>
<if test="endTime != null">
end_time = #{endTime,jdbcType=INTEGER},
</if>
<if test="orderNum != null">
order_num= #{orderNum,jdbcType=INTEGER},
</if>
<if test="logoUrl != null">
logo_url = #{logoUrl,jdbcType=VARCHAR},
</if>
<if test="coverUrl != null">
cover_url = #{coverUrl,jdbcType=VARCHAR},
</if>
<if test="webUrl != null">
web_url = #{webUrl,jdbcType=VARCHAR},
</if>
<if test="productPoolId != null">
product_pool_id = #{productPoolId,jdbcType=INTEGER},
</if>
<if test="yhChannel != null">
yh_channel=#{yhChannel,jdbcType=VARCHAR},
</if>
<if test="webCoverUrl != null">
web_cover_url=#{webCoverUrl,jdbcType=VARCHAR},
</if>
<if test="isShow != null">
is_show=#{isShow,jdbcType=CHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.yohobuy.platform.dal.event.model.SpecialActivity">
update special_activity
set sort = #{sort,jdbcType=CHAR},
title = #{title,jdbcType=VARCHAR},
plateform = #{plateform,jdbcType=CHAR},
promotion_name = #{promotionName,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=INTEGER},
start_time = #{startTime,jdbcType=INTEGER},
end_time = #{endTime,jdbcType=INTEGER},
logo_url = #{logoUrl,jdbcType=VARCHAR},
cover_url = #{coverUrl,jdbcType=VARCHAR},
order_num= #{orderNum,jdbcType=INTEGER},
web_url = #{webUrl,jdbcType=VARCHAR},
yh_channel = #{yhChannel,jdbcType=VARCHAR},
product_pool_id = #{productPoolId,jdbcType=INTEGER},
web_cover_url=#{webCoverUrl,jdbcType=VARCHAR},
is_show=#{isShow,jdbcType=CHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="querySpecialActivityByIDs" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from special_activity
where id in
<foreach collection="ids" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</select>
</mapper>