<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="cn.edu.ecnu.stu.bookstore.mapper.BookMapper">
    <insert id="insertTags">
        insert into t_book_tag(book_id, tag) values
        <foreach collection="tags" item="tag" separator=",">
            (#{book_id}, #{tag})
        </foreach>
    </insert>

    <insert id="insertPictures">
        insert into t_book_picture(book_id, picture) values
        <foreach collection="pictures" item="picture">
            (#{book_id}, #{picture})
        </foreach>
    </insert>

    <select id="batchSelect" resultType="cn.edu.ecnu.stu.bookstore.pojo.Book">
        select book_id, store_id, title, author, publisher, original_title, translator, pub_year, pages, price, binding, isbn, stock_level from t_book
            where store_id = #{storeId} and book_id in (
            <foreach collection="books" item="id" separator=",">
                #{id}
            </foreach>
            )
    </select>
</mapper>