<?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.oa.mapper.SysOaAiMessageMapper">

    <resultMap type="SysOaAiMessageVo" id="SysOaAiMessageResult">
        <result property="messageId" column="message_id"/>
        <result property="conversationId" column="conversation_id"/>
        <result property="role" column="role"/>
        <result property="content" column="content"/>
        <result property="renderType" column="render_type"/>
        <result property="tokens" column="tokens"/>
        <result property="cost" column="cost"/>
        <result property="messageOrder" column="message_order"/>
        <result property="createTime" column="create_time"/>
        <result property="createBy" column="create_by"/>
    </resultMap>

    <sql id="selectSysOaAiMessageVo">
        select message_id, conversation_id, role, content, render_type, tokens, cost, message_order, create_time, create_by
        from sys_oa_ai_message
    </sql>

    <select id="selectMessagesByConversationId" parameterType="Long" resultMap="SysOaAiMessageResult">
        <include refid="selectSysOaAiMessageVo"/>
        where conversation_id = #{conversationId}
        order by message_order asc
    </select>

</mapper> 