PromotionActivityMapper.xml
6.3 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
<?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.yoho.ufo.dal.PromotionActivityMapper" >
<resultMap id="BaseResultMap" type="com.yoho.ufo.dal.model.PromotionActivity" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="activity_name" property="activityName" jdbcType="VARCHAR" />
<result column="label" property="label" jdbcType="VARCHAR" />
<result column="start_time" property="startTime" jdbcType="INTEGER" />
<result column="end_time" property="endTime" jdbcType="INTEGER" />
<result column="promotion_type" property="promotionType" jdbcType="TINYINT" />
<result column="product_limit_type" property="productLimitType" jdbcType="VARCHAR" />
<result column="status" property="status" jdbcType="TINYINT" />
<result column="join_limit_type" property="joinLimitType" jdbcType="INTEGER" />
<result column="join_limit_times" property="joinLimitTimes" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
<result column="update_time" property="updateTime" jdbcType="INTEGER" />
<result column="business_client" property="businessClient" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, activity_name, start_time, end_time, promotion_type, product_scope_type,
product_limit_type, is_coupon, all_times_limit, day_times_limit, status, create_time,
update_time, create_user_id, update_user_id
</sql>
<select id="selectActivityWithinTime" resultMap="BaseResultMap">
select id, business_client from promotion_activity
where <![CDATA[ end_time > #{startTime, jdbcType=INTEGER} ]]>
and <![CDATA[ start_time < #{endTime, jdbcType=INTEGER} ]]>
and id != #{activityId, jdbcType=INTEGER}
and status = 1
</select>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
id, activity_name, label, start_time, end_time, promotion_type, product_limit_type, join_limit_type, join_limit_times, status, business_client
from promotion_activity
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from promotion_activity
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.yoho.ufo.dal.model.PromotionActivity" keyProperty="id" useGeneratedKeys="true">
insert into promotion_activity ( activity_name, label, start_time,
end_time, promotion_type,
product_limit_type, join_limit_type, join_limit_times,
status, create_time, update_time, business_client
)
values (#{activityName,jdbcType=VARCHAR},#{label,jdbcType=VARCHAR}, #{startTime,jdbcType=INTEGER},
#{endTime,jdbcType=INTEGER}, #{promotionType,jdbcType=TINYINT},
#{productLimitType,jdbcType=VARCHAR}, #{joinLimitType,jdbcType=TINYINT}, #{joinLimitTimes,jdbcType=INTEGER},
#{status,jdbcType=TINYINT}, #{createTime,jdbcType=INTEGER},
#{updateTime,jdbcType=INTEGER}, #{businessClient,jdbcType=VARCHAR}
)
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yoho.ufo.dal.model.PromotionActivity" >
update promotion_activity
<set >
<if test="status != null" >
status = #{status,jdbcType=TINYINT},
</if>
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.yoho.ufo.dal.model.PromotionActivity" >
update promotion_activity
set activity_name = #{activityName,jdbcType=VARCHAR},
label = #{label,jdbcType=VARCHAR},
start_time = #{startTime, jdbcType=INTEGER},
end_time = #{endTime,jdbcType=INTEGER},
promotion_type = #{promotionType,jdbcType=TINYINT},
product_limit_type = #{productLimitType,jdbcType=VARCHAR},
join_limit_type = #{joinLimitType,jdbcType=TINYINT},
join_limit_times = #{joinLimitTimes,jdbcType=INTEGER},
status = #{status,jdbcType=TINYINT},
update_time = #{updateTime,jdbcType=INTEGER},
business_client = #{businessClient, jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectCountByCondition" resultType="java.lang.Integer" >
select count(1)
from promotion_activity
where 1=1
<if test="record.id != null" >
and id = #{record.id,jdbcType=INTEGER}
</if>
<if test="record.activityName != null" >
<![CDATA[ AND instr(activity_name ,#{record.activityName}) > 0 ]]>
</if>
<if test="record.status != null">
<if test="record.status == 4">
<!--已关闭-->
and status= 2
</if>
<if test="record.status == 3">
<!--已结束-->
and end_time <![CDATA[< ]]> #{currentTime}
and status != 2
</if>
<if test="record.status == 2">
<!--进行中-->
and start_time <![CDATA[<= ]]> #{currentTime}
and end_time >= #{currentTime}
and status != 2
</if>
<if test="record.status == 1">
<!--未开始-->
and start_time > #{currentTime}
and status != 2
</if>
</if>
</select>
<select id="selectListByPage" resultMap="BaseResultMap" >
select
id, activity_name, label, promotion_type, start_time, end_time, status
from promotion_activity
where 1=1
<if test="record.id != null" >
and id = #{record.id,jdbcType=INTEGER}
</if>
<if test="record.activityName != null" >
<![CDATA[ AND instr(activity_name ,#{record.activityName}) > 0 ]]>
</if>
<if test="record.status != null">
<if test="record.status == 4">
<!--已关闭-->
and status= 2
</if>
<if test="record.status == 3">
<!--已结束-->
and end_time <![CDATA[< ]]> #{currentTime}
and status != 2
</if>
<if test="record.status == 2">
<!--进行中-->
and start_time <![CDATA[<= ]]> #{currentTime}
and end_time >= #{currentTime}
and status != 2
</if>
<if test="record.status == 1">
<!--未开始-->
and start_time > #{currentTime}
and status != 2
</if>
</if>
order by id desc
limit #{record.start},#{record.size}
</select>
</mapper>