<?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.GoodsImageMapper">

    <update id="removeGoodsImageByGoodsId" parameterType="Long">
        update goods_image
        set del_flag = 1
        where goods_id = #{goodsId}
    </update>

    <insert id="insertBatch" parameterType="GoodsImage" >
        insert into goods_image
        (goods_id, url, face_img, type, sorting,  create_by, create_time)
        values
        <foreach collection="list" item="item" separator=",">
            (#{item.goodsId}, #{item.url}, #{item.faceImg}, #{item.type}, #{item.sorting}, #{item.createBy}, #{item.createTime})
        </foreach>
        ;
    </insert>

    <resultMap type="GoodsServerVO" id="GoodsServerVOResult">
        <result property="goodsId"    column="goods_id"    />
        <result property="serverId"    column="server_id"    />
        <result property="goodsServerPrice"    column="goods_server_price"    />
        <result property="realName"    column="real_name"    />
        <result property="phone"    column="phone"    />
        <result property="serverLevel"    column="server_level"    />
    </resultMap>
    <select id="goodsImageList" resultMap="GoodsImageResult">
        <include refid="selectGoodsImageVo"/>
        <where>
            del_flag = 0
            and goods_id in
            <foreach collection="list" item="id" open="(" close=")" separator=",">
                #{id}
            </foreach>
        </where>
        order by sorting asc
    </select>

</mapper>
