<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd" >
<mapper namespace="com.pcloud.book.keywords.dao.impl.BookGuideReplyDaoImpl">

    <insert id="batchInsert" parameterType="bookGuideReply" useGeneratedKeys="true" keyProperty="id" flushCache="true">
        <foreach collection="list" item="item" index="index" separator=";">
            INSERT INTO book_guide_reply (
            book_guide_id, reply_type, content, description, link_url,pic_url, serve_id, serve_type, create_user, create_time
            )
            VALUES
            (
            #{item.bookGuideId, jdbcType=BIGINT}, #{item.replyType, jdbcType=TINYINT}, #{item.content, jdbcType=VARCHAR},
            #{item.description, jdbcType=VARCHAR}, #{item.linkUrl, jdbcType=VARCHAR},#{item.picUrl, jdbcType=VARCHAR}
            ,#{item.serveId, jdbcType=BIGINT},#{item.serveType, jdbcType=VARCHAR},#{item.createUser, jdbcType=BIGINT},now()
            )
        </foreach>
    </insert>

    <!--删除回复内容-->
    <update id="deleteByGuideId" parameterType="Long">
        update book_guide_reply
        <set>
            is_delete = 1,
            update_time = NOW()
        </set>
        where book_guide_id = #{_parameter,jdbcType=BIGINT}
    </update>

    <!--获取欢迎语回复消息-->
    <select id="getReplyMessage" resultType="ReplyMessageVO" parameterType="Long">
        select
            id, reply_type replyType, content, description, link_url linkUrl,pic_url picUrl, serve_id serveId, serve_type serveType
        from
            book_guide_reply
        where
            book_guide_id = #{_parameter,jdbcType=BIGINT} and is_delete = 0
    </select>


    <update id="updateServeInfo" parameterType="map">
        update
            book_guide_reply
        set
            content = #{content},
            pic_url = #{picUrl}
        where
            serve_id = #{serveId,jdbcType=BIGINT} and serve_type = #{serveType}
    </update>

</mapper>