<?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.java2nb.novel.mapper.CrawlBookMapper">

    <select id="queryNeedUpdateBook" resultType="com.java2nb.novel.entity.Book">

        select id,crawl_source_id,crawl_book_id,crawl_last_time,pic_url,word_count
        from book where last_index_update_time > #{startDate} and crawl_source_id is not null
        order by crawl_last_time
        limit ${limit}


    </select>

    <select id="queryTotalWordCount" parameterType="long" resultType="int">

        select sum(word_count) from book_index where book_id = #{bookId}
    </select>

    <update id="updateCrawlLastTime">
        update book set crawl_last_time = #{currentDate}
        where id in
        <foreach item="book" collection="books" open="(" separator="," close=")">
            #{book.id}
        </foreach>
    </update>


</mapper>