<?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.aicall.mapper.CcLlmAgentAccountMapper">
    
    <resultMap type="CcLlmAgentAccount" id="CcLlmAgentAccountResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="accountJson"    column="account_json"    />
        <result property="providerClassName"    column="provider_class_name"    />
        <result property="accountEntity"    column="account_entity"    />
        <result property="interruptFlag"    column="interrupt_flag"    />
        <result property="interruptKeywords"    column="interrupt_keywords"    />
        <result property="interruptIgnoreKeywords"    column="interrupt_ignore_keywords"    />
        <result property="intentionTips"    column="intention_tips"    />
        <result property="concurrentNum"    column="concurrent_num"    />
        <result property="transferManualDigit"    column="transfer_manual_digit"    />
        <result property="kbCatId"    column="kb_cat_id"    />
    </resultMap>

    <sql id="selectCcLlmAgentAccountVo">
        select id, name, account_json, provider_class_name, account_entity, interrupt_flag, interrupt_keywords, interrupt_ignore_keywords, intention_tips, concurrent_num, transfer_manual_digit, kb_cat_id from cc_llm_agent_account
    </sql>

    <select id="selectCcLlmAgentAccountList" parameterType="CcLlmAgentAccount" resultMap="CcLlmAgentAccountResult">
        <include refid="selectCcLlmAgentAccountVo"/>
        <where>  
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="providerClassName != null  and providerClassName != ''"> and provider_class_name like concat('%', #{providerClassName}, '%')</if>
        </where>
        order by id desc
    </select>
    
    <select id="selectCcLlmAgentAccountById" parameterType="Integer" resultMap="CcLlmAgentAccountResult">
        <include refid="selectCcLlmAgentAccountVo"/>
        where id = #{id}
    </select>

    <insert id="insertCcLlmAgentAccount" parameterType="CcLlmAgentAccount">
        insert into cc_llm_agent_account
        <trim prefix="(" suffix=")" suffixOverrides=",">
            id,
            name,
            account_json,
            provider_class_name,
            account_entity,
            interrupt_flag,
            interrupt_keywords,
            interrupt_ignore_keywords,
            intention_tips,
            concurrent_num,
            transfer_manual_digit,
            kb_cat_id,
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                   #{id},
                   #{name},
                   #{accountJson},
                   #{providerClassName},
                   #{accountEntity},
                   #{interruptFlag},
                   #{interruptKeywords},
                   #{interruptIgnoreKeywords},
                   #{intentionTips},
                   #{concurrentNum},
                   #{transferManualDigit},
                   #{kbCatId},
        </trim>
    </insert>

    <update id="updateCcLlmAgentAccount" parameterType="CcLlmAgentAccount">
        update cc_llm_agent_account
        <trim prefix="SET" suffixOverrides=",">
            name = #{name},
            account_json = #{accountJson},
            provider_class_name = #{providerClassName},
            account_entity = #{accountEntity},
            interrupt_flag = #{interruptFlag},
            interrupt_keywords = #{interruptKeywords},
            interrupt_ignore_keywords = #{interruptIgnoreKeywords},
            intention_tips = #{intentionTips},
            concurrent_num = #{concurrentNum},
            transfer_manual_digit = #{transferManualDigit},
            kb_cat_id = #{kbCatId},
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteCcLlmAgentAccountById" parameterType="Integer">
        delete from cc_llm_agent_account where id = #{id}
    </delete>

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

</mapper>