PrizeMapper.xml
3.01 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
<?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.PrizeMapper">
<resultMap id="BaseResultMap" type="com.yoho.lottery.dal.model.Prize">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="lottery_id" jdbcType="INTEGER" property="lotteryId" />
<result column="gift_id" jdbcType="INTEGER" property="giftId" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="prize_type" jdbcType="VARCHAR" property="prizeType" />
<result column="prize_value" jdbcType="VARCHAR" property="prizeValue" />
<result column="total" jdbcType="INTEGER" property="total" />
<result column="remain" jdbcType="INTEGER" property="remain" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="image" jdbcType="VARCHAR" property="image" />
</resultMap>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from prize
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.yoho.lottery.dal.model.Prize">
insert into prize (id, lottery_id, gift_id,
name, prize_type, prize_value,
total, remark, remain, image
)
values (#{id,jdbcType=INTEGER}, #{lotteryId,jdbcType=INTEGER}, #{giftId,jdbcType=INTEGER},
#{name,jdbcType=VARCHAR}, #{prizeType,jdbcType=VARCHAR}, #{prizeValue,jdbcType=VARCHAR},
#{total,jdbcType=INTEGER}, #{remark,jdbcType=VARCHAR}, #{remain,jdbcType=INTEGER}, #{image,jdbcType=VARCHAR}
)
</insert>
<update id="updateByPrimaryKey" parameterType="com.yoho.lottery.dal.model.Prize">
update prize
set lottery_id = #{lotteryId,jdbcType=INTEGER},
gift_id = #{giftId,jdbcType=INTEGER},
name = #{name,jdbcType=VARCHAR},
prize_type = #{prizeType,jdbcType=VARCHAR},
prize_value = #{prizeValue,jdbcType=VARCHAR},
total = #{total,jdbcType=INTEGER},
remark = #{remark,jdbcType=VARCHAR},
remain = #{remain,jdbcType=INTEGER},
image = #{image,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="subtractPrize" parameterType="java.lang.Integer">
update prize
set remain = remain - 1
where id = #{id,jdbcType=INTEGER} and remain > 0
</update>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select id, lottery_id, gift_id, name, prize_type, prize_value, total, remark, remain, image
from prize
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByLotteryId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select id, lottery_id, gift_id, name, prize_type, prize_value, total, remark, remain, image
from prize
where lottery_id = #{lotteryId,jdbcType=INTEGER}
</select>
<select id="selectAll" resultMap="BaseResultMap">
select id, lottery_id, gift_id, name, prize_type, prize_value, total, remark, remain, image
from prize
</select>
</mapper>