wangzhibo
2026-08-30 c8515170fd399b4d2dfaebb59128d4674e58915e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?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="xiaozhi.modules.agent.dao.AgentDao">
    <!-- 获取智能体的设备数量 -->
    <select id="getDeviceCountByAgentId" resultType="java.lang.Integer">
        SELECT COUNT(*) FROM ai_device WHERE agent_id = #{agentId}
    </select>
 
    <resultMap id="AgentInfoMap" type="xiaozhi.modules.agent.vo.AgentInfoVO">
        <id column="id"           property="id"/>
        <result column="userId"    property="userId"/>
        <result column="agentCode" property="agentCode"/>
        <result column="agentName" property="agentName"/>
        <result column="asrModelId" property="asrModelId"/>
        <result column="vadModelId" property="vadModelId"/>
        <result column="llmModelId" property="llmModelId"/>
        <result column="slmModelId" property="slmModelId"/>
        <result column="vllmModelId" property="vllmModelId"/>
        <result column="ttsModelId" property="ttsModelId"/>
        <result column="ttsVoiceId" property="ttsVoiceId"/>
        <result column="ttsLanguage" property="ttsLanguage"/>
        <result column="ttsVolume" property="ttsVolume"/>
        <result column="ttsRate" property="ttsRate"/>
        <result column="ttsPitch" property="ttsPitch"/>
        <result column="memModelId" property="memModelId"/>
        <result column="intentModelId" property="intentModelId"/>
 
        <result column="chatHistoryConf" property="chatHistoryConf"/>
        <result column="systemPrompt" property="systemPrompt"/>
        <result column="summaryMemory" property="summaryMemory"/>
        <result column="langCode" property="langCode"/>
        <result column="language" property="language"/>
        <result column="sort" property="sort"/>
        <result column="creator" property="creator"/>
        <result column="createdAt" property="createdAt"/>
        <result column="updater" property="updater"/>
        <result column="updatedAt" property="updatedAt"/>
        <collection property="functions"
                    ofType="xiaozhi.modules.agent.entity.AgentPluginMapping">
            <id column="functionId" property="id"/>
            <result column="functionAgentId" property="agentId"/>
            <result column="pluginId" property="pluginId"/>
            <result column="paramInfo" property="paramInfo"/>
        </collection>
    </resultMap>
 
    <select id="selectAgentInfoById" resultMap="AgentInfoMap">
        SELECT a.id,
               a.user_id           AS userId,
               a.agent_code        AS agentCode,
               a.agent_name        AS agentName,
               a.asr_model_id      AS asrModelId,
               a.vad_model_id      AS vadModelId,
               a.llm_model_id      AS llmModelId,
               a.slm_model_id      AS slmModelId,
               a.vllm_model_id     AS vllmModelId,
               a.tts_model_id      AS ttsModelId,
               a.tts_voice_id      AS ttsVoiceId,
               a.tts_language      AS ttsLanguage,
               a.tts_volume        AS ttsVolume,
               a.tts_rate          AS ttsRate,
               a.tts_pitch         AS ttsPitch,
               a.mem_model_id      AS memModelId,
               a.intent_model_id   AS intentModelId,
               a.chat_history_conf AS chatHistoryConf,
               a.system_prompt     AS systemPrompt,
               a.summary_memory    AS summaryMemory,
               a.lang_code         AS langCode,
               a.language          AS language,
               a.sort,
               a.creator,
               a.created_at        AS createdAt,
               a.updater,
               a.updated_at        AS updatedAt,
               f.id                AS functionId,
               f.agent_id          AS functionAgentId,
               f.plugin_id         AS pluginId,
               f.param_info        AS paramInfo
        FROM ai_agent a
        LEFT JOIN ai_agent_plugin_mapping f ON f.agent_id = a.id
        WHERE a.id = #{agentId}
        ORDER BY f.id ASC
    </select>
 
    <select id="selectByIdForUpdate" resultType="xiaozhi.modules.agent.entity.AgentEntity">
        SELECT *
        FROM ai_agent
        WHERE id = #{agentId}
        FOR UPDATE
    </select>
 
    <update id="updateSnapshotFields">
        UPDATE ai_agent
        SET agent_code = #{agent.agentCode,jdbcType=VARCHAR},
            agent_name = #{agent.agentName,jdbcType=VARCHAR},
            asr_model_id = #{agent.asrModelId,jdbcType=VARCHAR},
            vad_model_id = #{agent.vadModelId,jdbcType=VARCHAR},
            llm_model_id = #{agent.llmModelId,jdbcType=VARCHAR},
            slm_model_id = #{agent.slmModelId,jdbcType=VARCHAR},
            vllm_model_id = #{agent.vllmModelId,jdbcType=VARCHAR},
            tts_model_id = #{agent.ttsModelId,jdbcType=VARCHAR},
            tts_voice_id = #{agent.ttsVoiceId,jdbcType=VARCHAR},
            tts_language = #{agent.ttsLanguage,jdbcType=VARCHAR},
            tts_volume = #{agent.ttsVolume,jdbcType=INTEGER},
            tts_rate = #{agent.ttsRate,jdbcType=INTEGER},
            tts_pitch = #{agent.ttsPitch,jdbcType=INTEGER},
            mem_model_id = #{agent.memModelId,jdbcType=VARCHAR},
            intent_model_id = #{agent.intentModelId,jdbcType=VARCHAR},
            chat_history_conf = #{agent.chatHistoryConf,jdbcType=INTEGER},
            system_prompt = #{agent.systemPrompt,jdbcType=LONGVARCHAR},
            summary_memory = #{agent.summaryMemory,jdbcType=LONGVARCHAR},
            lang_code = #{agent.langCode,jdbcType=VARCHAR},
            language = #{agent.language,jdbcType=VARCHAR},
            sort = #{agent.sort,jdbcType=INTEGER},
            updater = #{agent.updater,jdbcType=BIGINT},
            updated_at = #{agent.updatedAt,jdbcType=TIMESTAMP}
        WHERE id = #{agent.id}
    </update>
 
</mapper>