<?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.CcLlmKbCatMapper">
    
    <resultMap type="CcLlmKbCat" id="CcLlmKbCatResult">
        <result property="id"    column="id"    />
        <result property="cat"    column="cat"    />
        <result property="description"    column="description"    />
    </resultMap>

    <sql id="selectCcLlmKbCatVo">
        select id, cat, description from cc_llm_kb_cat
    </sql>

    <select id="selectCcLlmKbCatList" parameterType="CcLlmKbCat" resultMap="CcLlmKbCatResult">
        <include refid="selectCcLlmKbCatVo"/>
        <where>  
            <if test="cat != null  and cat != ''"> and cat = #{cat}</if>
            <if test="description != null  and description != ''"> and description = #{description}</if>
        </where>
    </select>
    
    <select id="selectCcLlmKbCatById" parameterType="Long" resultMap="CcLlmKbCatResult">
        <include refid="selectCcLlmKbCatVo"/>
        where id = #{id}
    </select>

    <insert id="insertCcLlmKbCat" parameterType="CcLlmKbCat" useGeneratedKeys="true" keyProperty="id">
        insert into cc_llm_kb_cat
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="cat != null">cat,</if>
            <if test="description != null">description,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="cat != null">#{cat},</if>
            <if test="description != null">#{description},</if>
         </trim>
    </insert>

    <update id="updateCcLlmKbCat" parameterType="CcLlmKbCat">
        update cc_llm_kb_cat
        <trim prefix="SET" suffixOverrides=",">
            <if test="cat != null">cat = #{cat},</if>
            <if test="description != null">description = #{description},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteCcLlmKbCatById" parameterType="Long">
        delete from cc_llm_kb_cat where id = #{id}
    </delete>

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

</mapper>