<?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.fs.store.mapper.FsStoreProductAttrValueMapper">

    <resultMap type="FsStoreProductAttrValue" id="FsStoreProductAttrValueResult">
        <result property="id"    column="id"    />
        <result property="productId"    column="product_id"    />
        <result property="sku"    column="sku"    />
        <result property="stock"    column="stock"    />
        <result property="sales"    column="sales"    />
        <result property="price"    column="price"    />
        <result property="image"    column="image"    />
        <result property="cost"    column="cost"    />
        <result property="agentPrice"    column="agent_price"    />
        <result property="barCode"    column="bar_code"    />
        <result property="groupBarCode"    column="group_bar_code"    />
        <result property="otPrice"    column="ot_price"    />
        <result property="weight"    column="weight"    />
        <result property="volume"    column="volume"    />
        <result property="brokerage"    column="brokerage"    />
        <result property="brokerageTwo"    column="brokerage_two"    />
        <result property="brokerageThree"    column="brokerage_three"    />
        <result property="integral"    column="integral"    />
    </resultMap>

    <sql id="selectFsStoreProductAttrValueVo">
        select id, product_id, sku, stock, sales, price, image, cost,agent_price, bar_code,group_bar_code, ot_price, weight, volume, brokerage, brokerage_two,brokerage_three, integral from fs_store_product_attr_value
    </sql>

    <select id="selectFsStoreProductAttrValueList" parameterType="FsStoreProductAttrValue" resultMap="FsStoreProductAttrValueResult">
        <include refid="selectFsStoreProductAttrValueVo"/>
        <where>
            <if test="productId != null "> and product_id = #{productId}</if>
            <if test="sku != null  and sku != ''"> and sku = #{sku}</if>
            <if test="stock != null "> and stock = #{stock}</if>
            <if test="sales != null "> and sales = #{sales}</if>
            <if test="price != null "> and price = #{price}</if>
            <if test="image != null  and image != ''"> and image = #{image}</if>
            <if test="cost != null "> and cost = #{cost}</if>
            <if test="agentPrice != null "> and agent_price = #{agentPrice}</if>
            <if test="barCode != null  and barCode != ''"> and bar_code = #{barCode}</if>
            <if test="otPrice != null "> and ot_price = #{otPrice}</if>
            <if test="weight != null "> and weight = #{weight}</if>
            <if test="volume != null "> and volume = #{volume}</if>
            <if test="brokerage != null "> and brokerage = #{brokerage}</if>
            <if test="brokerageTwo != null "> and brokerage_two = #{brokerageTwo}</if>
            <if test="brokerageThree != null "> and brokerage_three = #{brokerageThree}</if>
            <if test="integral != null "> and integral = #{integral}</if>
        </where>
    </select>

    <select id="selectFsStoreProductAttrValueById" parameterType="Long" resultMap="FsStoreProductAttrValueResult">
        <include refid="selectFsStoreProductAttrValueVo"/>
        where id = #{id}
    </select>

    <insert id="insertFsStoreProductAttrValue" parameterType="FsStoreProductAttrValue" useGeneratedKeys="true" keyProperty="id">
        insert into fs_store_product_attr_value
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="productId != null">product_id,</if>
            <if test="sku != null and sku != ''">sku,</if>
            <if test="stock != null">stock,</if>
            <if test="sales != null">sales,</if>
            <if test="price != null">price,</if>
            <if test="image != null">image,</if>
            <if test="cost != null">cost,</if>
            <if test="agentPrice != null">agent_price,</if>
            <if test="barCode != null">bar_code,</if>
            <if test="groupBarCode != null">group_bar_code,</if>
            <if test="otPrice != null">ot_price,</if>
            <if test="weight != null">weight,</if>
            <if test="volume != null">volume,</if>
            <if test="brokerage != null">brokerage,</if>
            <if test="brokerageTwo != null">brokerage_two,</if>
            <if test="brokerageThree != null">brokerage_three,</if>
            <if test="integral != null">integral,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="productId != null">#{productId},</if>
            <if test="sku != null and sku != ''">#{sku},</if>
            <if test="stock != null">#{stock},</if>
            <if test="sales != null">#{sales},</if>
            <if test="price != null">#{price},</if>
            <if test="image != null">#{image},</if>
            <if test="cost != null">#{cost},</if>
            <if test="agentPrice != null">#{agentPrice},</if>
            <if test="barCode != null">#{barCode},</if>
            <if test="groupBarCode != null">#{groupBarCode},</if>
            <if test="otPrice != null">#{otPrice},</if>
            <if test="weight != null">#{weight},</if>
            <if test="volume != null">#{volume},</if>
            <if test="brokerage != null">#{brokerage},</if>
            <if test="brokerageTwo != null">#{brokerageTwo},</if>
            <if test="brokerageThree != null">#{brokerageThree},</if>
            <if test="integral != null">#{integral},</if>
         </trim>
    </insert>

    <update id="updateFsStoreProductAttrValue" parameterType="FsStoreProductAttrValue">
        update fs_store_product_attr_value
        <trim prefix="SET" suffixOverrides=",">
            <if test="productId != null">product_id = #{productId},</if>
            <if test="sku != null and sku != ''">sku = #{sku},</if>
            <if test="stock != null">stock = #{stock},</if>
            <if test="sales != null">sales = #{sales},</if>
            <if test="price != null">price = #{price},</if>
            <if test="image != null">image = #{image},</if>
            <if test="cost != null">cost = #{cost},</if>
            <if test="agentPrice != null">agent_price = #{agentPrice},</if>
            <if test="barCode != null">bar_code = #{barCode},</if>
            <if test="groupBarCode != null">group_bar_code = #{groupBarCode},</if>
            <if test="otPrice != null">ot_price = #{otPrice},</if>
            <if test="weight != null">weight = #{weight},</if>
            <if test="volume != null">volume = #{volume},</if>
            <if test="brokerage != null">brokerage = #{brokerage},</if>
            <if test="brokerageTwo != null">brokerage_two = #{brokerageTwo},</if>
            <if test="brokerageThree != null">brokerage_three = #{brokerageThree},</if>
            <if test="integral != null">integral = #{integral},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteFsStoreProductAttrValueById" parameterType="Long">
        delete from fs_store_product_attr_value where id = #{id}
    </delete>

    <delete id="deleteFsStoreProductAttrValueByIds" parameterType="String">
        delete from fs_store_product_attr_value where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

</mapper>
