<?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.purui.prims.headless.server.persistence.mapper.ChatContextMapper">

    <resultMap id="ChatContextDO"
               type="com.purui.prims.headless.server.persistence.dataobject.ChatContextDO">
        <id column="chat_id" property="chatId"/>
        <result column="modified_at" property="modifiedAt"/>
        <result column="user" property="user"/>
        <result column="query_text" property="queryText"/>
        <result column="semantic_parse" property="semanticParse"/>
        <!--<result column="ext_data" property="extData"/>-->
    </resultMap>

    <select id="getContextByChatId" resultMap="ChatContextDO">
        select *
        from pr_chat_context
        where chat_id = #{chatId}
        limit 1
    </select>

    <insert id="addContext" parameterType="com.purui.prims.headless.server.persistence.dataobject.ChatContextDO">
        insert into pr_chat_context (chat_id, user, query_text, semantic_parse)
        values (#{chatId}, #{user}, #{queryText}, #{semanticParse})
    </insert>
    <update id="updateContext">
        update pr_chat_context
        set query_text=#{queryText},
            semantic_parse=#{semanticParse}
        where chat_id = #{chatId}
    </update>

</mapper>