<?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.younike.system.mapper.GoodsSpecificationMapper">

    <update id="removeGoodsSpecificationByGoodsId" parameterType="Long">
        UPDATE goods_specification
        SET del_flag = 1
        WHERE goods_id = #{goodsId}
    </update>

    <insert id="insertBatch" parameterType="com.younike.system.domain.GoodsSpecification" >
        <foreach collection="goodsSpecificationList" item="item" index="index" separator=";">
            INSERT INTO goods_specification (specification_desc, times, current_price, scribing_price, goods_id, merchant_id, create_by, update_by)
            VALUES  (#{item.specificationDesc}, #{item.times}, #{item.currentPrice}, #{item.scribingPrice}, #{item.goodsId}, #{item.merchantId}, #{item.createBy}, #{item.updateBy})
        </foreach>
    </insert>

    <select id="listByGoodsIds" resultMap="GoodsSpecificationResult">
        <include refid="selectGoodsSpecificationVo"/>
        <where>
            del_flag = 0
            and goods_id in
            <foreach collection="list" item="id" open="(" close=")" separator=",">
                #{id}
            </foreach>
        </where>
    </select>

</mapper>