GoodsMapper.xml
2.54 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
<?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.ufo.dal.GoodsMapper">
<resultMap id="BaseResultMap" type="com.yoho.ufo.dal.model.Goods">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="product_id" jdbcType="INTEGER" property="productId" />
<result column="color_id" jdbcType="INTEGER" property="colorId" />
<result column="color_name" jdbcType="VARCHAR" property="colorName" />
<result column="goods_name" jdbcType="VARCHAR" property="goodsName" />
<result column="color_image" jdbcType="VARCHAR" property="colorImage" />
<result column="is_default" jdbcType="CHAR" property="isDefault" />
</resultMap>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from goods
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.yoho.ufo.dal.model.Goods" useGeneratedKeys="true" keyProperty="id" >
insert into goods (id, product_id, color_id,
color_name, goods_name, color_image,
is_default)
values (#{id,jdbcType=INTEGER}, #{productId,jdbcType=INTEGER}, #{colorId,jdbcType=INTEGER},
#{colorName,jdbcType=VARCHAR}, #{goodsName,jdbcType=VARCHAR}, #{colorImage,jdbcType=VARCHAR},
#{isDefault,jdbcType=CHAR})
</insert>
<update id="updateByPrimaryKey" parameterType="com.yoho.ufo.dal.model.Goods">
update goods
set product_id = #{productId,jdbcType=INTEGER},
color_id = #{colorId,jdbcType=INTEGER},
color_name = #{colorName,jdbcType=VARCHAR},
goods_name = #{goodsName,jdbcType=VARCHAR},
color_image = #{colorImage,jdbcType=VARCHAR},
is_default = #{isDefault,jdbcType=CHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select id, product_id, color_id, color_name, goods_name, color_image, is_default
from goods
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectAll" resultMap="BaseResultMap">
select id, product_id, color_id, color_name, goods_name, color_image, is_default
from goods
</select>
<select id="selectByProductId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select id, product_id, color_id, color_name, goods_name, color_image, is_default
from goods
where product_id in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</select>
</mapper>