<?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.CcAsrLanguagesMapper">
    
    <resultMap type="CcAsrLanguages" id="CcAsrLanguagesResult">
        <result property="id"    column="id"    />
        <result property="asrProvider"    column="asr_provider"    />
        <result property="models"    column="models"    />
        <result property="languageCode"    column="language_code"    />
        <result property="languageName"    column="language_name"    />
    </resultMap>

    <sql id="selectCcAsrLanguagesVo">
        select id, asr_provider, models, language_code, language_name from cc_asr_languages
    </sql>

    <select id="selectCcAsrLanguagesList" parameterType="CcAsrLanguages" resultMap="CcAsrLanguagesResult">
        <include refid="selectCcAsrLanguagesVo"/>
        <where>  
            <if test="asrProvider != null  and asrProvider != ''"> and asr_provider = #{asrProvider}</if>
            <if test="models != null  and models != ''"> and models = #{models}</if>
            <if test="languageCode != null  and languageCode != ''"> and language_code = #{languageCode}</if>
            <if test="languageName != null  and languageName != ''"> and language_name like concat('%', #{languageName}, '%')</if>
        </where>
    </select>
    
    <select id="selectCcAsrLanguagesById" parameterType="Long" resultMap="CcAsrLanguagesResult">
        <include refid="selectCcAsrLanguagesVo"/>
        where id = #{id}
    </select>

    <insert id="insertCcAsrLanguages" parameterType="CcAsrLanguages" useGeneratedKeys="true" keyProperty="id">
        insert into cc_asr_languages
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="asrProvider != null and asrProvider != ''">asr_provider,</if>
            <if test="models != null and models != ''">models,</if>
            <if test="languageCode != null and languageCode != ''">language_code,</if>
            <if test="languageName != null and languageName != ''">language_name,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="asrProvider != null and asrProvider != ''">#{asrProvider},</if>
            <if test="models != null and models != ''">#{models},</if>
            <if test="languageCode != null and languageCode != ''">#{languageCode},</if>
            <if test="languageName != null and languageName != ''">#{languageName},</if>
         </trim>
    </insert>

    <update id="updateCcAsrLanguages" parameterType="CcAsrLanguages">
        update cc_asr_languages
        <trim prefix="SET" suffixOverrides=",">
            <if test="asrProvider != null and asrProvider != ''">asr_provider = #{asrProvider},</if>
            <if test="models != null and models != ''">models = #{models},</if>
            <if test="languageCode != null and languageCode != ''">language_code = #{languageCode},</if>
            <if test="languageName != null and languageName != ''">language_name = #{languageName},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteCcAsrLanguagesById" parameterType="Long">
        delete from cc_asr_languages where id = #{id}
    </delete>

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

</mapper>