This commit is contained in:
2025-11-04 18:49:37 +08:00
parent b95fff224b
commit 8850a06fea
103 changed files with 15337 additions and 771 deletions

View File

@@ -7,12 +7,15 @@
<id column="id" property="id" jdbcType="VARCHAR"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="avatar" property="avatar" jdbcType="VARCHAR"/>
<result column="description" property="description" jdbcType="VARCHAR"/>
<result column="system_prompt" property="systemPrompt" jdbcType="LONGVARCHAR"/>
<result column="model_name" property="modelName" jdbcType="VARCHAR"/>
<result column="model_provider" property="modelProvider" jdbcType="VARCHAR"/>
<result column="temperature" property="temperature" jdbcType="DECIMAL"/>
<result column="max_tokens" property="maxTokens" jdbcType="INTEGER"/>
<result column="top_p" property="topP" jdbcType="DECIMAL"/>
<result column="dify_app_id" property="difyAppId" jdbcType="VARCHAR"/>
<result column="dify_api_key" property="difyApiKey" jdbcType="VARCHAR"/>
<result column="status" property="status" jdbcType="INTEGER"/>
<result column="creator" property="creator" jdbcType="VARCHAR"/>
<result column="updater" property="updater" jdbcType="VARCHAR"/>
@@ -24,9 +27,9 @@
<!-- 基础字段 -->
<sql id="Base_Column_List">
id, name, avatar, system_prompt, model_name, model_provider, temperature,
max_tokens, top_p, status, creator, updater, create_time, update_time,
delete_time, deleted
id, name, avatar, description, system_prompt, model_name, model_provider,
temperature, max_tokens, top_p, dify_app_id, dify_api_key, status,
creator, updater, create_time, update_time, delete_time, deleted
</sql>
<!-- 通用条件 -->
@@ -48,7 +51,129 @@
</where>
</sql>
<!-- selectAiAgentConfigs -->
<!-- 插入智能体配置 -->
<insert id="insertAgentConfig" parameterType="org.xyzh.common.dto.ai.TbAiAgentConfig">
INSERT INTO tb_ai_agent_config (
id, name, avatar, description, system_prompt, model_name, model_provider,
temperature, max_tokens, top_p, dify_app_id, dify_api_key, status,
creator, updater, create_time, update_time, deleted
) VALUES (
#{id}, #{name}, #{avatar}, #{description}, #{systemPrompt}, #{modelName}, #{modelProvider},
#{temperature}, #{maxTokens}, #{topP}, #{difyAppId}, #{difyApiKey}, #{status},
#{creator}, #{updater}, #{createTime}, #{updateTime}, #{deleted}
)
</insert>
<!-- 更新智能体配置(动态更新) -->
<update id="updateAgentConfig" parameterType="org.xyzh.common.dto.ai.TbAiAgentConfig">
UPDATE tb_ai_agent_config
<set>
<if test="name != null and name != ''">name = #{name},</if>
<if test="avatar != null">avatar = #{avatar},</if>
<if test="description != null">description = #{description},</if>
<if test="systemPrompt != null">system_prompt = #{systemPrompt},</if>
<if test="modelName != null">model_name = #{modelName},</if>
<if test="modelProvider != null">model_provider = #{modelProvider},</if>
<if test="temperature != null">temperature = #{temperature},</if>
<if test="maxTokens != null">max_tokens = #{maxTokens},</if>
<if test="topP != null">top_p = #{topP},</if>
<if test="difyAppId != null">dify_app_id = #{difyAppId},</if>
<if test="difyApiKey != null">dify_api_key = #{difyApiKey},</if>
<if test="status != null">status = #{status},</if>
<if test="updater != null">updater = #{updater},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</set>
WHERE id = #{ID} AND deleted = 0
</update>
<!-- 逻辑删除智能体配置 -->
<update id="deleteAgentConfig" parameterType="org.xyzh.common.dto.ai.TbAiAgentConfig">
UPDATE tb_ai_agent_config
SET deleted = 1,
delete_time = NOW(),
updater = #{updater}
WHERE id = #{ID} AND deleted = 0
</update>
<!-- 根据ID查询智能体配置 -->
<select id="selectAgentConfigById" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM tb_ai_agent_config
WHERE id = #{agentId} AND deleted = 0
</select>
<!-- 查询所有智能体配置(支持过滤) -->
<select id="selectAgentConfigs" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM tb_ai_agent_config
WHERE deleted = 0
<if test="filter != null">
<if test="filter.name != null and filter.name != ''">
AND name LIKE CONCAT('%', #{filter.name}, '%')
</if>
<if test="filter.status != null">
AND status = #{filter.status}
</if>
<if test="filter.modelProvider != null and filter.modelProvider != ''">
AND model_provider = #{filter.modelProvider}
</if>
</if>
ORDER BY create_time DESC
</select>
<!-- 分页查询智能体配置 -->
<select id="selectAgentConfigsPage" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM tb_ai_agent_config
WHERE deleted = 0
<if test="filter != null">
<if test="filter.name != null and filter.name != ''">
AND name LIKE CONCAT('%', #{filter.name}, '%')
</if>
<if test="filter.status != null">
AND status = #{filter.status}
</if>
<if test="filter.modelProvider != null and filter.modelProvider != ''">
AND model_provider = #{filter.modelProvider}
</if>
</if>
ORDER BY create_time DESC
LIMIT #{pageParam.offset}, #{pageParam.pageSize}
</select>
<!-- 统计智能体配置总数 -->
<select id="countAgentConfigs" resultType="java.lang.Long">
SELECT COUNT(1)
FROM tb_ai_agent_config
WHERE deleted = 0
<if test="filter != null">
<if test="filter.name != null and filter.name != ''">
AND name LIKE CONCAT('%', #{filter.name}, '%')
</if>
<if test="filter.status != null">
AND status = #{filter.status}
</if>
<if test="filter.modelProvider != null and filter.modelProvider != ''">
AND model_provider = #{filter.modelProvider}
</if>
</if>
</select>
<!-- 根据名称统计数量 -->
<select id="countAgentConfigByName" resultType="java.lang.Integer">
SELECT COUNT(1)
FROM tb_ai_agent_config
WHERE name = #{name}
AND deleted = 0
<if test="excludeId != null and excludeId != ''">
AND id != #{excludeId}
</if>
</select>
<!-- selectAiAgentConfigs (原有方法保留兼容性) -->
<select id="selectAiAgentConfigs" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>