CouponMapper.xml
5.14 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
<?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.CouponMapper">
<resultMap id="BaseResultMap" type="com.yoho.ufo.model.coupon.Coupon">
<result column="id" property="id" jdbcType="INTEGER" />
<result column="coupon_token" property="couponToken" jdbcType="VARCHAR" />
<result column="coupon_name" property="couponName" jdbcType="VARCHAR" />
<result column="coupon_amount" property="couponAmount" jdbcType="FLOAT" />
<result column="coupon_type" property="couponType" jdbcType="INTEGER" />
<result column="coupon_num" property="couponNum" jdbcType="INTEGER" />
<result column="use_num" property="useNum" jdbcType="INTEGER" />
<result column="send_num" property="sendNum" jdbcType="INTEGER" />
<result column="use_limit_type" property="useLimitType" jdbcType="INTEGER" />
<result column="use_limit_value" property="useLimitValue" jdbcType="INTEGER" />
<result column="product_limit_type" property="productLimitType" jdbcType="INTEGER" />
<result column="product_limit_value" property="productLimitValue" jdbcType="VARCHAR" />
<result column="start_time" property="startTime" jdbcType="INTEGER" />
<result column="end_time" property="endTime" jdbcType="INTEGER" />
<result column="status" property="status" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
<result column="pid" property="pid" jdbcType="INTEGER" />
<result column="remark" property="remark" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List">
id,coupon_token,coupon_name,coupon_amount,coupon_type,coupon_num,use_num,send_num,
use_limit_type,use_limit_value,product_limit_type,product_limit_value,start_time,
end_time,status,create_time,pid,remark
</sql>
<insert id="insertOrUpdate" useGeneratedKeys="true" keyProperty="id">
insert into coupon(id,coupon_token,coupon_name,coupon_amount,coupon_type,coupon_num,use_num,send_num,
use_limit_type,
<if test="param.useLimitType == 2">
use_limit_value,
</if>
product_limit_type,
<if test="param.productLimitType != 1">
product_limit_value,
</if>
start_time,end_time,status,create_time,pid,remark)
values(#{param.id},#{param.couponToken},#{param.couponName},#{param.couponAmount},#{param.couponType}
,#{param.couponNum},#{param.useNum},#{param.sendNum},#{param.useLimitType},
<if test="param.useLimitType == 2">
#{param.useLimitValue},
</if>
#{param.productLimitType},
<if test="param.productLimitType != 1">
#{param.productLimitValue},
</if>
#{param.startTime},#{param.endTime},#{param.status},#{param.createTime},#{param.pid},#{param.remark})
on duplicate key update
coupon_name=#{param.couponName},coupon_amount=#{param.couponAmount},coupon_type=#{param.couponType},coupon_num=#{param.couponNum}
,use_num=#{param.useNum},send_num=#{param.sendNum},
use_limit_type=#{param.useLimitType},
<if test="param.useLimitType == 2">
use_limit_value=#{param.useLimitValue},
</if>
product_limit_type=#{param.productLimitType},
<if test="param.productLimitType != 1">
product_limit_value=#{param.productLimitValue},
</if>
start_time=#{param.startTime},end_time=#{param.endTime},status=#{param.status},pid=#{param.pid},remark=#{param.remark}
</insert>
<select id="selectTotalByCondition" resultType="java.lang.Integer">
select count(1) from coupon where 1=1
<if test="param.id != null">
and id=#{param.id}
</if>
<if test="param.couponName != null">
and coupon_name=#{param.couponName}
</if>
<if test="param.status != null">
and status=#{param.status}
</if>
<if test="param.startTime != null">
and start_time>=#{param.startTime}
</if>
<if test="param.endTime != null">
and end_time <![CDATA[<= ]]> #{param.endTime}
</if>
</select>
<select id="selectByCondition" resultType="com.yoho.ufo.model.coupon.Coupon">
select <include refid="Base_Column_List" /> from coupon where 1=1
<if test="param.id != null">
and id=#{param.id}
</if>
<if test="param.couponName != null">
and coupon_name=#{param.couponName}
</if>
<if test="param.status != null">
and status=#{param.status}
</if>
<if test="param.startTime != null">
and start_time>=#{param.startTime}
</if>
<if test="param.endTime != null">
and end_time <![CDATA[<= ]]> #{param.endTime}
</if>
order by id desc
limit #{param.start},#{param.size}
</select>
<select id="selectById" resultType="com.yoho.ufo.model.coupon.Coupon">
select <include refid="Base_Column_List" /> from coupon where id=#{id} limit 1;
</select>
</mapper>