ProductProfitMapper.xml
4.42 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
<?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.product.dal.ProductProfitMapper">
<resultMap id="BaseResultMap" type="com.yoho.product.model.ProductProfit">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="product_id" jdbcType="INTEGER" property="productId" />
<result column="profit_rate" jdbcType="DECIMAL" property="profitRate" />
<result column="update_time" jdbcType="INTEGER" property="updateTime" />
<result column="create_time" jdbcType="INTEGER" property="createTime" />
<result column="del_status" jdbcType="INTEGER" property="delStatus" />
<result column="edit_user_name" jdbcType="VARCHAR" property="editUserName" />
<result column="add_user_name" jdbcType="VARCHAR" property="addUserName" />
<result column="profit_max_price" jdbcType="DECIMAL" property="profitMaxPrice" />
<result column="profit_min_price" jdbcType="DECIMAL" property="profitMinPrice" />
</resultMap>
<select id="selectCount" resultType="java.lang.Integer" parameterType="java.lang.Integer">
select count(1) from product_profit
where del_status = 0
<if test="productId != null && productId > 0">
and product_id = #{productId, jdbcType=INTEGER}
</if>
</select>
<select id="selectById" resultMap="BaseResultMap" parameterType="java.lang.Integer">
select id, product_id, profit_rate, profit_max_price, profit_min_price
from product_profit
where id = #{id, jdbcType=INTEGER}
</select>
<select id="selectByCondition" resultMap="BaseResultMap">
select id, product_id, profit_rate, profit_max_price, profit_min_price, create_time, update_time, add_user_name, edit_user_name
from product_profit
where del_status = 0
<if test="productId != null && productId > 0">
and product_id = #{productId, jdbcType=INTEGER}
</if>
limit #{startIndex}, #{rows}
</select>
<update id="updateDelStatus" parameterType="java.lang.Integer">
update product_profit
set del_status = 1
where id = #{id, jdbcType=INTEGER}
</update>
<select id="selectByProductIds" resultMap="BaseResultMap">
select product_id, add_user_name, create_time from product_profit
where del_status = 0
and product_id in
<foreach collection="list" item="productId" separator="," open="(" close=")">
#{productId, jdbcType=INTEGER}
</foreach>
</select>
<insert id="insertBatchProductProfit">
replace into product_profit
(product_id, profit_rate, update_time, create_time, add_user_name, edit_user_name, profit_max_price, profit_min_price)
values
<foreach collection="list" item="item" separator=",">
(#{item.productId, jdbcType=INTEGER},#{item.profitRate, jdbcType=DECIMAL},
#{item.updateTime, jdbcType=INTEGER},#{item.createTime, jdbcType=INTEGER},
#{item.addUserName, jdbcType=INTEGER},#{item.editUserName, jdbcType=INTEGER},
#{item.profitMaxPrice, jdbcType=DECIMAL},#{item.profitMinPrice, jdbcType=DECIMAL}
)
</foreach>
</insert>
<update id="update">
update product_profit
set product_id = #{productId, jdbcType=INTEGER},
profit_rate = #{profitRate, jdbcType=DECIMAL},
profit_max_price = #{profitMaxPrice, jdbcType=DECIMAL},
profit_min_price = #{profitMinPrice, jdbcType=DECIMAL},
edit_user_name = #{editUserName, jdbcType=VARCHAR},
update_time = #{updateTime, jdbcType=INTEGER}
where id = #{id, jdbcType=INTEGER}
</update>
<select id="selectByProductId" resultType="java.lang.Integer" resultMap="BaseResultMap">
select id from product_profit
where del_status = 0 and product_id = #{productId, jdbcType=INTEGER}
limit 1
</select>
<insert id="insert">
replace into product_profit
(product_id, profit_rate, profit_max_price, profit_min_price, add_user_name, create_time)
values
(#{productId, jdbcType=INTEGER}, #{profitRate, jdbcType=DECIMAL},
#{profitMaxPrice, jdbcType=DECIMAL}, #{profitMinPrice, jdbcType=DECIMAL},
#{addUserName, jdbcType=VARCHAR}, #{createTime, jdbcType=INTEGER})
</insert>
</mapper>