<?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.ruoyi.base.mapper.DialogueLogMapper">
    
    <resultMap type="DialogueLog" id="DialogueLogResult">
        <result property="id"    column="id"    />
        <result property="robotCode"    column="robot_code"    />
        <result property="sessionId"    column="session_id"    />
        <result property="askTime"    column="ask_time"    />
        <result property="question"    column="question"    />
        <result property="answer"    column="answer"    />
        <result property="answerSummary"    column="answer_summary"    />
        <result property="hitType"    column="hit_type"    />
        <result property="sceneType"    column="scene_type"    />
        <result property="resultStatus"    column="result_status"    />
        <result property="errorMsg"    column="error_msg"    />
        <result property="rawRequest"    column="raw_request"    />
        <result property="rawResponse"    column="raw_response"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectDialogueLogVo">
        select id, robot_code, session_id, ask_time, question, answer, answer_summary, hit_type, scene_type, result_status, error_msg, raw_request, raw_response, create_time from robot_ops_dialogue_log
    </sql>

    <select id="selectDialogueLogList" parameterType="DialogueLog" resultMap="DialogueLogResult">
        <include refid="selectDialogueLogVo"/>
        <where>  
            <if test="robotCode != null  and robotCode != ''"> and robot_code = #{robotCode}</if>
            <if test="sessionId != null  and sessionId != ''"> and session_id = #{sessionId}</if>
            <if test="askTime != null "> and ask_time = #{askTime}</if>
            <if test="question != null  and question != ''"> and question = #{question}</if>
            <if test="answer != null  and answer != ''"> and answer = #{answer}</if>
            <if test="answerSummary != null  and answerSummary != ''"> and answer_summary = #{answerSummary}</if>
            <if test="hitType != null  and hitType != ''"> and hit_type = #{hitType}</if>
            <if test="sceneType != null  and sceneType != ''"> and scene_type = #{sceneType}</if>
            <if test="resultStatus != null  and resultStatus != ''"> and result_status = #{resultStatus}</if>
            <if test="errorMsg != null  and errorMsg != ''"> and error_msg = #{errorMsg}</if>
            <if test="rawRequest != null  and rawRequest != ''"> and raw_request = #{rawRequest}</if>
            <if test="rawResponse != null  and rawResponse != ''"> and raw_response = #{rawResponse}</if>
        </where>
    </select>
    
    <select id="selectDialogueLogById" parameterType="Long" resultMap="DialogueLogResult">
        <include refid="selectDialogueLogVo"/>
        where id = #{id}
    </select>

    <insert id="insertDialogueLog" parameterType="DialogueLog" useGeneratedKeys="true" keyProperty="id">
        insert into robot_ops_dialogue_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="robotCode != null">robot_code,</if>
            <if test="sessionId != null">session_id,</if>
            <if test="askTime != null">ask_time,</if>
            <if test="question != null">question,</if>
            <if test="answer != null">answer,</if>
            <if test="answerSummary != null">answer_summary,</if>
            <if test="hitType != null">hit_type,</if>
            <if test="sceneType != null">scene_type,</if>
            <if test="resultStatus != null">result_status,</if>
            <if test="errorMsg != null">error_msg,</if>
            <if test="rawRequest != null">raw_request,</if>
            <if test="rawResponse != null">raw_response,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="robotCode != null">#{robotCode},</if>
            <if test="sessionId != null">#{sessionId},</if>
            <if test="askTime != null">#{askTime},</if>
            <if test="question != null">#{question},</if>
            <if test="answer != null">#{answer},</if>
            <if test="answerSummary != null">#{answerSummary},</if>
            <if test="hitType != null">#{hitType},</if>
            <if test="sceneType != null">#{sceneType},</if>
            <if test="resultStatus != null">#{resultStatus},</if>
            <if test="errorMsg != null">#{errorMsg},</if>
            <if test="rawRequest != null">#{rawRequest},</if>
            <if test="rawResponse != null">#{rawResponse},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateDialogueLog" parameterType="DialogueLog">
        update robot_ops_dialogue_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="robotCode != null">robot_code = #{robotCode},</if>
            <if test="sessionId != null">session_id = #{sessionId},</if>
            <if test="askTime != null">ask_time = #{askTime},</if>
            <if test="question != null">question = #{question},</if>
            <if test="answer != null">answer = #{answer},</if>
            <if test="answerSummary != null">answer_summary = #{answerSummary},</if>
            <if test="hitType != null">hit_type = #{hitType},</if>
            <if test="sceneType != null">scene_type = #{sceneType},</if>
            <if test="resultStatus != null">result_status = #{resultStatus},</if>
            <if test="errorMsg != null">error_msg = #{errorMsg},</if>
            <if test="rawRequest != null">raw_request = #{rawRequest},</if>
            <if test="rawResponse != null">raw_response = #{rawResponse},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteDialogueLogById" parameterType="Long">
        delete from robot_ops_dialogue_log where id = #{id}
    </delete>

    <delete id="deleteDialogueLogByIds" parameterType="String">
        delete from robot_ops_dialogue_log where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>