LotteryRecordMapper.xml
4.26 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
<?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.lottery.dal.LotteryRecordMapper">
<resultMap id="BaseResultMap" type="com.yoho.lottery.dal.model.LotteryRecord">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="lottery_id" jdbcType="INTEGER" property="lotteryId" />
<result column="uid" jdbcType="INTEGER" property="uid" />
<result column="status" jdbcType="TINYINT" property="status" />
<result column="flag" jdbcType="VARCHAR" property="flag" />
<result column="prize_id" jdbcType="INTEGER" property="prizeId" />
<result column="mod_time" jdbcType="INTEGER" property="modTime" />
</resultMap>
<sql id="Base_Column_List" >
id, lottery_id, uid, status, flag, prize_id, mod_time
</sql>
<delete id="deleteByPrimaryKey">
delete from lottery_record_${shardFactor}
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert">
insert into lottery_record_${shardFactor} (id, lottery_id, uid,
status, flag, prize_id,
mod_time)
values (#{record.id,jdbcType=INTEGER}, #{record.lotteryId,jdbcType=INTEGER}, #{record.uid,jdbcType=INTEGER},
#{record.status,jdbcType=TINYINT}, #{record.flag,jdbcType=VARCHAR}, #{record.prizeId,jdbcType=INTEGER},
#{record.modTime,jdbcType=INTEGER})
</insert>
<update id="updateByPrimaryKey">
update lottery_record_${shardFactor}
set lottery_id = #{record.lotteryId,jdbcType=INTEGER},
uid = #{record.uid,jdbcType=INTEGER},
status = #{record.status,jdbcType=TINYINT},
flag = #{record.flag,jdbcType=VARCHAR},
prize_id = #{record.prizeId,jdbcType=INTEGER},
mod_time = #{record.modTime,jdbcType=INTEGER}
where id = #{record.id,jdbcType=INTEGER}
</update>
<select id="selectByPrimaryKey" resultMap="BaseResultMap">
select <include refid="Base_Column_List" />
from lottery_record_${shardFactor}
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByIds" resultMap="BaseResultMap">
select id, lottery_id, uid, status, flag, prize_id, mod_time
from lottery_record_${shardFactor}
where id in
<foreach collection="ids" item="id" index="index"
open="(" close=")" separator=",">
#{id}
</foreach>
</select>
<select id="selectAll" resultMap="BaseResultMap">
select <include refid="Base_Column_List" />
from lottery_record_${shardFactor}
</select>
<select id="selectOrderRecords" resultMap="BaseResultMap">
select <include refid="Base_Column_List" />
from lottery_record_${shardFactor}
where lottery_id = #{lotteryId,jdbcType=INTEGER}
and uid = #{userId,jdbcType=INTEGER}
<if test="orderCode != null and orderCode !=''">
and flag = #{orderCode,jdbcType=VARCHAR}
</if>
<if test="lotteryId != null">
and lottery_id = #{lotteryId,jdbcType=INTEGER}
</if>
</select>
<select id="selectOrderRecordIds" resultType="java.lang.Integer">
select id
from lottery_record_${shardFactor}
where uid = #{userId,jdbcType=INTEGER}
<if test="lotteryId != null">
and lottery_id = #{lotteryId,jdbcType=INTEGER}
</if>
<if test="orderCode != null and orderCode !=''">
and flag = #{orderCode,jdbcType=INTEGER}
</if>
</select>
<select id="selectUserLotteryPrizeCount" resultType="java.lang.Integer">
select case when count(*) is null then 0 else count(*) end count
from lottery_record_${shardFactor}
where lottery_id = #{lotteryId,jdbcType=INTEGER}
and uid = #{userId,jdbcType=INTEGER} and prize_id is not null
</select>
<select id="selectLotteryPrizeInfo" resultType="com.yoho.lottery.dal.model.LotteryPrizeInfo">
select prize_id as prizeId , count(*) as count
from lottery_record_${shardFactor}
where lottery_id = #{lotteryId,jdbcType=INTEGER} and prize_id is not null
group by prize_id
</select>
<select id="selectByUidAndOrderCodes" resultMap="BaseResultMap">
select <include refid="Base_Column_List" />
from lottery_record_${shardFactor}
where uid = #{userId,jdbcType=INTEGER} and flag in
<foreach item="item" index="index" collection="orderCodes" open="(" separator="," close=")">
#{item}
</foreach>
</select>
</mapper>