<?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.CcTtsAliyunMapper">
    
    <resultMap type="CcTtsAliyun" id="CcTtsAliyunResult">
        <result property="id"    column="id"    />
        <result property="voiceName"    column="voice_name"    />
        <result property="voiceCode"    column="voice_code"    />
        <result property="voiceEnabled"    column="voice_enabled"    />
        <result property="voiceSource"    column="voice_source"    />
        <result property="priority"    column="priority"    />
        <result property="provider"    column="provider"    />
    </resultMap>

    <sql id="selectCcTtsAliyunVo">
        select id, voice_name, voice_code, voice_enabled, voice_source, priority, provider from cc_tts_aliyun
    </sql>

    <select id="selectCcTtsAliyunList" parameterType="CcTtsAliyun" resultMap="CcTtsAliyunResult">
        <include refid="selectCcTtsAliyunVo"/>
        <where>  
            <if test="voiceName != null  and voiceName != ''"> and voice_name like concat('%', #{voiceName}, '%')</if>
            <if test="voiceCode != null  and voiceCode != ''"> and voice_code = #{voiceCode}</if>
            <if test="voiceEnabled != null "> and voice_enabled = #{voiceEnabled}</if>
            <if test="voiceSource != null  and voiceSource != ''"> and voice_source = #{voiceSource}</if>
            <if test="priority != null "> and priority = #{priority}</if>
            <if test="provider != null  and provider != ''"> and provider = #{provider}</if>
        </where>
         order by priority asc
    </select>
    
    <select id="selectCcTtsAliyunById" parameterType="Integer" resultMap="CcTtsAliyunResult">
        <include refid="selectCcTtsAliyunVo"/>
        where id = #{id}
    </select>

    <insert id="insertCcTtsAliyun" parameterType="CcTtsAliyun" useGeneratedKeys="true" keyProperty="id">
        insert into cc_tts_aliyun
        <trim prefix="(" suffix=")" suffixOverrides=",">
            voice_name,
            voice_code,
            voice_enabled,
            voice_source,
            priority,
            provider,
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            #{voiceName},
            #{voiceCode},
            #{voiceEnabled},
            #{voiceSource},
            #{priority},
            #{provider},
        </trim>
    </insert>

    <update id="updateCcTtsAliyun" parameterType="CcTtsAliyun">
        update cc_tts_aliyun
        <trim prefix="SET" suffixOverrides=",">
            voice_name = #{voiceName},
            voice_code = #{voiceCode},
            voice_enabled = #{voiceEnabled},
            voice_source = #{voiceSource},
            priority =  #{priority},
            provider = #{provider}
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteCcTtsAliyunById" parameterType="Integer">
        delete from cc_tts_aliyun where id = #{id}
    </delete>

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

</mapper>