<?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.fs.company.mapper.CompanyVoiceDialogMapper">
    
    <resultMap type="CompanyVoiceDialog" id="CompanyVoiceDialogResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="resultName"    column="result_name"    />
        <result property="resultId"    column="result_id"    />
        <result property="callNum"    column="call_num"    />
        <result property="remark"    column="remark"    />
        <result property="createTime"    column="create_time"    />
        <result property="createUser"    column="create_user"    />
    </resultMap>

    <sql id="selectCompanyVoiceDialogVo">
        select id, name, result_name, result_id, call_num, remark, create_time, create_user from company_voice_dialog
    </sql>

    <select id="selectCompanyVoiceDialogList" parameterType="CompanyVoiceDialog" resultMap="CompanyVoiceDialogResult">
        <include refid="selectCompanyVoiceDialogVo"/>
        <where>  
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="resultName != null  and resultName != ''"> and result_name like concat('%', #{resultName}, '%')</if>
            <if test="resultId != null "> and result_id = #{resultId}</if>
            <if test="callNum != null  and callNum != ''"> and call_num = #{callNum}</if>
            <if test="createUser != null "> and create_user = #{createUser}</if>
        </where>
    </select>
    
    <select id="selectCompanyVoiceDialogById" parameterType="Long" resultMap="CompanyVoiceDialogResult">
        <include refid="selectCompanyVoiceDialogVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertCompanyVoiceDialog" parameterType="CompanyVoiceDialog" useGeneratedKeys="true" keyProperty="id">
        insert into company_voice_dialog
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null">name,</if>
            <if test="resultName != null">result_name,</if>
            <if test="resultId != null">result_id,</if>
            <if test="callNum != null">call_num,</if>
            <if test="remark != null">remark,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createUser != null">create_user,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null">#{name},</if>
            <if test="resultName != null">#{resultName},</if>
            <if test="resultId != null">#{resultId},</if>
            <if test="callNum != null">#{callNum},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createUser != null">#{createUser},</if>
         </trim>
    </insert>

    <update id="updateCompanyVoiceDialog" parameterType="CompanyVoiceDialog">
        update company_voice_dialog
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="resultName != null">result_name = #{resultName},</if>
            <if test="resultId != null">result_id = #{resultId},</if>
            <if test="callNum != null">call_num = #{callNum},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createUser != null">create_user = #{createUser},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteCompanyVoiceDialogById" parameterType="Long">
        delete from company_voice_dialog where id = #{id}
    </delete>

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