ChannelProductMapper.xml
2.92 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
<?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.sincere.wechatbusiness.mapper.ChannelProductMapper">
<resultMap id="ChannelProductMap" type="com.sincere.wechatbusiness.model.ChannelProduct">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="channelId" jdbcType="INTEGER" property="channelId" />
<result column="productId" jdbcType="INTEGER" property="productId" />
<result column="product_name" jdbcType="VARCHAR" property="productName" />
<result column="price" jdbcType="VARCHAR" property="price" />
<result column="img_url" jdbcType="VARCHAR" property="imgUrl" />
<result column="channel_price" jdbcType="VARCHAR" property="channelPrice" />
<result column="caption" jdbcType="VARCHAR" property="caption" />
<result column="state" jdbcType="INTEGER" property="state"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="promotion_price" jdbcType="VARCHAR" property="promotionPrice" />
<result column="end_time" jdbcType="TIMESTAMP" property="endTime" />
<result column="title" jdbcType="VARCHAR" property="title" />
</resultMap>
<select id="getList" parameterType="java.lang.Integer" resultMap="ChannelProductMap">
select * from channel_product where state=1 and channelId=#{id} order by create_time
</select>
<insert id="insert" parameterType="com.sincere.wechatbusiness.model.ChannelProduct">
insert into channel_product (channelId,productId,product_name,price,img_url)
values (#{channelId,jdbcType=INTEGER},#{productId,jdbcType=INTEGER}, #{productName,jdbcType=VARCHAR}, #{price,jdbcType=VARCHAR}, #{imgUrl,jdbcType=VARCHAR}
)
</insert>
<update id="update" parameterType="com.sincere.wechatbusiness.model.ChannelProduct">
update channel_product
<trim prefix="set" suffixOverrides=",">
<if test="channelPrice!=null and channelPrice!=''">
channel_price=#{channelPrice},
</if>
<if test="caption!=null and caption!=''">
caption=#{caption},
</if>
<if test="promotionPrice!=null and promotionPrice!=''">
promotion_price=#{promotionPrice},
</if>
<if test="endTime!=null">
end_time=#{endTime},
</if>
<if test="title!=null and title!=''">
title=#{title},
</if>
</trim>
where id = #{id}
</update>
<update id="deleteChannelProduct" parameterType="java.lang.Integer">
update channel_product set state=0 where channelId=#{id}
</update>
<select id="getDetail" parameterType="java.lang.Integer" resultMap="ChannelProductMap">
select * from channel_product where id=#{id}
</select>
</mapper>