active-rule-mapper.xml
2.79 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
<?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.ActiveRuleDao">
<resultMap type="ActiveRuleInfo" id="ActiveRule">
<id property="id" column="id" />
<result property="activeId" column="active_id" />
<result property="giftId" column="gift_id" />
<result property="giftAmount" column="gift_amount" />
<result property="startRule" column="start_rule" />
<result property="endRule" column="end_rule" />
<result property="sort" column="sort" />
<result property="createAt" column="create_at" />
<result property="createBy" column="create_by" />
<association property="activeGiftInfo" javaType="ActiveGiftInfo">
<id property="id" column="giftid" />
<result property="activeId" column="active_id" />
<result property="giftName" column="gift_name" />
<result property="giftCode" column="gift_code" />
<result property="giftAmount" column="gift_amount" />
<result property="giftRemainAmount" column="gift_remain_amount" />
<result property="giftType" column="gift_type" />
<result property="giftPrice" column="gift_price" />
<result property="createAt" column="createat" />
<result property="createBy" column="createby" />
</association>
</resultMap>
<sql id="active_rule_field">
r.id, r.active_id, r.gift_id, r.gift_amount, r.start_rule, r.end_rule, r.sort, r.create_at, r.create_by,
g.id giftid, g.active_id, g.gift_name, g.gift_code, g.gift_amount, g.gift_remain_amount, g.gift_type,
g.gift_price, g.create_at createat, g.create_by createby
</sql>
<select id="queryByConfigId" parameterType="int" resultMap="ActiveRule">
select <include refid="active_rule_field" />
from active_rule r
inner join active_gift g
on r.gift_id = g.id
where r.active_id = #{activeId}
</select>
<select id="queryRuleCountByConfigId" parameterType="int" resultType="int">
select count(1) from active_rule
where active_id = #{activeId}
</select>
<insert id="insert" parameterType="ActiveRuleInfo">
insert into active_rule(active_id, gift_id, gift_amount, start_rule, end_rule, sort, create_at, create_by)
values(#{activeId}, #{giftId}, #{giftAmount}, #{startRule}, #{endRule}, #{sort}, CURRENT_TIMESTAMP, #{createBy})
</insert>
<update id="update" parameterType="ActiveRuleInfo">
update active_rule set gift_id = #{giftId}, gift_amount = #{giftAmount}, start_rule = #{startRule},
end_rule = #{endRule}, sort = #{sort}, create_by = #{createBy}
where id = #{id}
</update>
<delete id="delete" parameterType="int">
delete from active_rule where id = #{id}
</delete>
<delete id="deleteByActiveId" parameterType="int">
delete from active_rule where active_id = #{activeId}
</delete>
</mapper>