point-active-mapper.xml
3.95 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
<?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">
<!-- @author tongxiaochuan -->
<mapper namespace="com.cjs.cms.dao.user.point.PointActiveDao">
<sql id="point_active_field">
id, name, type, start_date, end_date, gift_amount, gift_remain, expired_date,
executer, remark, status, create_at, create_by
</sql>
<insert id="insert" parameterType="PointActiveInfo"
useGeneratedKeys="true" keyProperty="id">
insert into point_active(name,
type, start_date, end_date, gift_amount, gift_remain, expired_date, executer, remark, status,
create_at, create_by)
values(#{name}, #{type}, #{startDate}, #{endDate}, #{giftAmount}, #{giftRemain}, #{expiredDate}, #{executer},
#{remark}, #{status}, CURRENT_TIMESTAMP, #{createBy})
</insert>
<resultMap type="PointActiveInfo" id="ConfigInfo">
<id property="id" column="id" />
<result property="name" column="name" />
<result property="type" column="type" />
<result property="startDate" column="start_date" />
<result property="endDate" column="end_date" />
<result property="giftAmount" column="gift_amount"/>
<result property="giftRemain" column="gift_remain"/>
<result property="expiredDate" column="expired_date" />
<result property="executer" column="executer" />
<result property="remark" column="remark" />
<result property="status" column="status" />
<result property="createAt" column="create_at" />
<result property="createBy" column="create_by" />
<collection property="rules" ofType="PointRuleInfo" column="id"
select="queryRules" />
</resultMap>
<select id="queryRules" parameterType="int" resultType="PointRuleInfo">
select * from point_rule where active_id = #{id} order by sort asc
</select>
<select id="queryActiveById" parameterType="int" resultMap="ConfigInfo">
select <include refid="point_active_field" />
from point_active
where id = #{id}
</select>
<update id="update" parameterType="PointActiveInfo">
update point_active set name = #{name}, type = #{type}, start_date = #{startDate},
end_date = #{endDate}, gift_amount = #{giftAmount}, gift_remain = #{giftRemain}, expired_date = #{expiredDate},
executer = #{executer}, remark = #{remark}, status = #{status},
create_at = CURRENT_TIMESTAMP, create_by = #{createBy}
where id = #{id}
</update>
<sql id="searchCondition">
where 1=1
<if test="name != null and name != ''">
and name = #{name}
</if>
<if test="type != null and type != ''">
and type = #{type}
</if>
<if test="status != null and status != ''">
and status = #{status}
</if>
<if test="startDate != null and startDate != ''">
<![CDATA[and start_date >= #{startDate} ]]>
</if>
<if test="endDate != null and endDate != ''">
<![CDATA[and end_date <= #{endDate} ]]>
</if>
<if test="nowDate != null and nowDate != ''">
and #{nowDate} between start_date and end_date
</if>
</sql>
<select id="search" parameterType="map" resultMap="ConfigInfo">
select <include refid="point_active_field" />
from point_active
<include refid="searchCondition" />
order by id desc
<include refid="common.pageLimit" />
</select>
<select id="searchTotal" parameterType="map" resultType="int">
select count(1) from point_active
<include refid="searchCondition" />
</select>
<update id="updateStatus" parameterType="map">
update point_active set status = #{status}
where id = #{id}
</update>
<select id="queryActive" parameterType="map" resultMap="ConfigInfo">
select <include refid="point_active_field" />
from point_active
<include refid="searchCondition" />
</select>
<!-- 更新剩余配额数量 -->
<update id="updateGiftRemain" parameterType="PointActiveInfo">
update point_active set gift_remain = #{giftRemain}
where id = #{id}
</update>
<select id="queryAll" resultType="PointActiveInfo">
select <include refid="point_active_field" />
from point_active where status != '0'
</select>
</mapper>