<?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.cool.store.mapper.order.StoreWishlistOptionMapper">

    <insert id="insertBatch">
        INSERT INTO zxjp_store_wishlist_option
        (wishlist_id, option_id, quantity, deleted, create_time, update_time)
        VALUES
        <foreach collection="list" item="item" separator=",">
            (#{item.wishlistId}, #{item.optionId}, #{item.quantity}, 0, NOW(), NOW())
        </foreach>
    </insert>

    <update id="softDeleteByWishlistIds">
        UPDATE zxjp_store_wishlist_option
        SET deleted = 1,
            update_time = NOW()
        WHERE deleted = 0
          AND wishlist_id IN
          <foreach collection="wishlistIds" item="wishlistId" open="(" separator="," close=")">
            #{wishlistId}
          </foreach>
    </update>

    <select id="listByWishlistIds" resultType="com.cool.store.entity.order.StoreWishlistOptionDO">
        SELECT id, wishlist_id, option_id, quantity, deleted, create_time, update_time
        FROM zxjp_store_wishlist_option
        WHERE deleted = 0
          AND wishlist_id IN
          <foreach collection="wishlistIds" item="wishlistId" open="(" separator="," close=")">
            #{wishlistId}
          </foreach>
        ORDER BY id ASC
    </select>

</mapper>
