<?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.yiqi.core.mapper.GoodsSkuSpecMapper">

    <resultMap type="com.yiqi.core.domain.GoodsSkuSpec" id="GoodsSkuSpecResult">
            <result property="id" column="id"/>
            <result property="goodsSkuId" column="goods_sku_id"/>
            <result property="specName" column="spec_name"/>
            <result property="specValue" column="spec_value"/>
            <result property="delFlag" column="del_flag"/>
            <result property="createBy" column="create_by"/>
            <result property="createById" column="create_by_id"/>
            <result property="createTime" column="create_time"/>
            <result property="updateBy" column="update_by"/>
            <result property="updateById" column="update_by_id"/>
            <result property="updateTime" column="update_time"/>
            <result property="remark" column="remark"/>
    </resultMap>

    <sql id="selectGoodsSkuSpecVo">
        select * from goods_sku_spec
    </sql>

    <select id="selectGoodsSkuSpecList"  resultMap="GoodsSkuSpecResult">
        <include refid="selectGoodsSkuSpecVo"/>
        <where>
        </where>
    </select>

    <select id="selectGoodsSkuSpecById" parameterType="Long"
            resultMap="GoodsSkuSpecResult">
            <include refid="selectGoodsSkuSpecVo"/>
            where id = #{id}
    </select>
    <select id="getSkuSpecListBySkuId" resultMap="GoodsSkuSpecResult">
        <include refid="selectGoodsSkuSpecVo"/>
        where goods_sku_id = #{skuId}
    </select>

    <insert id="insertGoodsSkuSpec"  useGeneratedKeys="true"
            keyProperty="id">
        insert into goods_sku_spec
        <trim prefix="(" suffix=")" suffixOverrides=",">
                    <if test="goodsSkuId != null">goods_sku_id,
                    </if>
                    <if test="specName != null">spec_name,
                    </if>
                    <if test="specValue != null">spec_value,
                    </if>
                    <if test="delFlag != null">del_flag,
                    </if>
                    <if test="createBy != null">create_by,
                    </if>
                    <if test="createById != null">create_by_id,
                    </if>
                    <if test="createTime != null">create_time,
                    </if>
                    <if test="updateBy != null">update_by,
                    </if>
                    <if test="updateById != null">update_by_id,
                    </if>
                    <if test="updateTime != null">update_time,
                    </if>
                    <if test="remark != null">remark,
                    </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                    <if test="goodsSkuId != null">#{goodsSkuId},
                    </if>
                    <if test="specName != null">#{specName},
                    </if>
                    <if test="specValue != null">#{specValue},
                    </if>
                    <if test="delFlag != null">#{delFlag},
                    </if>
                    <if test="createBy != null">#{createBy},
                    </if>
                    <if test="createById != null">#{createById},
                    </if>
                    <if test="createTime != null">#{createTime},
                    </if>
                    <if test="updateBy != null">#{updateBy},
                    </if>
                    <if test="updateById != null">#{updateById},
                    </if>
                    <if test="updateTime != null">#{updateTime},
                    </if>
                    <if test="remark != null">#{remark},
                    </if>
        </trim>
    </insert>

    <update id="updateGoodsSkuSpec" >
        update goods_sku_spec
        <trim prefix="SET" suffixOverrides=",">
                    <if test="goodsSkuId != null">goods_sku_id =
                        #{goodsSkuId},
                    </if>
                    <if test="specName != null">spec_name =
                        #{specName},
                    </if>
                    <if test="specValue != null">spec_value =
                        #{specValue},
                    </if>
                    <if test="delFlag != null">del_flag =
                        #{delFlag},
                    </if>
                    <if test="createBy != null">create_by =
                        #{createBy},
                    </if>
                    <if test="createById != null">create_by_id =
                        #{createById},
                    </if>
                    <if test="createTime != null">create_time =
                        #{createTime},
                    </if>
                    <if test="updateBy != null">update_by =
                        #{updateBy},
                    </if>
                    <if test="updateById != null">update_by_id =
                        #{updateById},
                    </if>
                    <if test="updateTime != null">update_time =
                        #{updateTime},
                    </if>
                    <if test="remark != null">remark =
                        #{remark},
                    </if>
        </trim>
        where id = #{id}
    </update>

        <delete id="deleteGoodsSkuSpecById" parameterType="Long">
            delete from goods_sku_spec where id = #{id}
        </delete>

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



</mapper>