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
<?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.knowledge.dao.KnowledgeBaseDao">
 
    <resultMap id="BaseResultMap" type="xiaozhi.modules.knowledge.entity.KnowledgeBaseEntity">
        <id property="id" column="id" jdbcType="VARCHAR"/>
        <result property="datasetId" column="dataset_id" jdbcType="VARCHAR"/>
        <result property="ragModelId" column="rag_model_id" jdbcType="VARCHAR"/>
        <result property="name" column="name" jdbcType="VARCHAR"/>
        <result property="description" column="description" jdbcType="VARCHAR"/>
        <result property="status" column="status" jdbcType="TINYINT"/>
        <result property="creator" column="creator" jdbcType="BIGINT"/>
        <result property="createdAt" column="created_at" jdbcType="TIMESTAMP"/>
        <result property="updater" column="updater" jdbcType="BIGINT"/>
        <result property="updatedAt" column="updated_at" jdbcType="TIMESTAMP"/>
    </resultMap>
 
    <!-- 根据知识库ID删除相关的插件映射记录 -->
    <delete id="deletePluginMappingByKnowledgeBaseId">
        DELETE FROM ai_agent_plugin_mapping 
        WHERE plugin_id = #{knowledgeBaseId}
    </delete>
 
    <!-- 通用维度原子更新知识库统计信息 -->
    <update id="updateStatsAfterChange">
        UPDATE ai_rag_dataset
        SET document_count = document_count + #{docDelta},
            chunk_count = chunk_count + #{chunkDelta},
            token_num = token_num + #{tokenDelta},
            updated_at = NOW()
        WHERE dataset_id = #{datasetId}
    </update>
 
</mapper>