<?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.tencent.supersonic.chat.persistence.mapper.ChatParseMapper">

    <resultMap id="ChatParse" type="com.tencent.supersonic.chat.persistence.dataobject.ChatParseDO">
        <id column="question_id" property="questionId"/>
        <result column="chat_id" property="chatId"/>
        <result column="parse_id" property="parseId"/>
        <result column="create_time" property="createTime"/>
        <result column="query_text" property="queryText"/>
        <result column="user_name" property="userName"/>
        <result column="parse_info" property="parseInfo"/>
        <result column="is_candidate" property="isCandidate"/>
    </resultMap>

    <insert id="batchSaveParseInfo" parameterType="com.tencent.supersonic.chat.persistence.dataobject.ChatParseDO">
        insert into s2_chat_parse
               (question_id, chat_id, parse_id, create_time, query_text, user_name, parse_info,is_candidate)
        values
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.questionId}, #{item.chatId}, #{item.parseId}, #{item.createTime}, #{item.queryText}, #{item.userName}, #{item.parseInfo}, #{item.isCandidate})
        </foreach>
    </insert>

    <update id="updateParseInfo" parameterType="com.tencent.supersonic.chat.persistence.dataobject.ChatParseDO">
        update s2_chat_parse
        set parse_info = #{parseInfo}
        where question_id = #{questionId} and parse_id = #{parseId}
    </update>

    <select id="getParseInfo" resultMap="ChatParse">
        select *
        from s2_chat_parse
        where question_id = #{questionId} and parse_id = #{parseId} limit 1
    </select>

    <select id="getParseInfoList" resultMap="ChatParse">
        select *
        from s2_chat_parse
        where question_id in
        <foreach item="questionId" index="index" collection="list" open="(" separator="," close=")">
            #{questionId}
        </foreach>
    </select>

</mapper>
