active-config-mapper.xml
3.68 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">
<!-- @author tongxiaochuan -->
<mapper namespace="com.cjs.cms.dao.user.point.ActiveConfigDao">
<sql id="active_config_field">
id, name, type, active_account, start_date, end_date, addition, remark, status, create_at, create_by
</sql>
<select id="queryById" parameterType="int" resultType="ActiveConfigInfo">
select <include refid="active_config_field" /> from active_config
where id = #{id} and status = 2
</select>
<sql id="queryCondition">
where 1=1
<if test="type != null and type != ''">
and type = #{type}
</if>
<if test="status != null and status != ''">
and status = #{status}
</if>
<if test="nowDate != null and nowDate != ''">
<![CDATA[and #{nowDate} between start_date and end_date ]]>
</if>
</sql>
<select id="queryActive" parameterType="map" resultType="ActiveConfigInfo">
select <include refid="active_config_field" />
from active_config
<include refid="queryCondition" />
</select>
<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>
</sql>
<select id="search" parameterType="map" resultType="ActiveConfigInfo">
select <include refid="active_config_field" />
from active_config
<include refid="searchCondition" />
order by id desc
<include refid="common.pageLimit" />
</select>
<select id="searchTotal" parameterType="map" resultType="int">
select count(1) from active_config
<include refid="searchCondition" />
</select>
<insert id="insert" parameterType="ActiveConfigInfo" useGeneratedKeys="true" keyProperty="id">
insert into active_config(name, type, active_account, start_date, end_date, addition, remark, status, create_at, create_by)
values(#{name}, #{type}, #{activeAccount}, #{startDate}, #{endDate}, #{addition}, #{remark}, #{status}, CURRENT_TIMESTAMP,
#{createBy})
</insert>
<update id="update" parameterType="ActiveConfigInfo">
update active_config set name = #{name}, type = #{type}, active_account = #{activeAccount}, start_date = #{startDate},
end_date = #{endDate}, addition = #{addition}, remark = #{remark}, status = #{status}, create_at = CURRENT_TIMESTAMP,
create_by = #{createBy} where id = #{id}
</update>
<resultMap type="ActiveConfigInfo" id="ConfigInfo">
<id property="id" column="id"/>
<result property="name" column="name"/>
<result property="type" column="type"/>
<result property="activeAccount" column="active_account"/>
<result property="startDate" column="start_date"/>
<result property="endDate" column="end_date"/>
<result property="addition" column="addition"/>
<result property="remark" column="remark"/>
<result property="status" column="status"/>
<result property="createAt" column="create_at"/>
<result property="createBy" column="create_by"/>
<collection property="gifts" ofType="ActiveGiftInfo" column="id" select="queryGifts" />
</resultMap>
<select id="queryGifts" parameterType="int" resultType="ActiveGiftInfo">
select * from active_gift where active_id = #{id}
</select>
<select id="queryByIdForUpdate" parameterType="int" resultMap="ConfigInfo">
select t.id, t.name, t.type, t.active_account, t.start_date, t.end_date, t.addition, t.remark,
t.status, t.create_at, t.create_by
from active_config t
where t.id = #{id}
</select>
<!-- 取消活动 -->
<update id="cancel" parameterType="int">
update active_config set status = 0
where id = #{activeId}
</update>
</mapper>