<?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.CompanyVoiceBlacklistMapper">
    
    <resultMap type="CompanyVoiceBlacklist" id="CompanyVoiceBlacklistResult">
        <result property="blacklistId"    column="blacklist_id"    />
        <result property="mobile"    column="mobile"    />
        <result property="companyId"    column="company_id"    />
        <result property="status"    column="status"    />
        <result property="remark"    column="remark"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectCompanyVoiceBlacklistVo">
        select blacklist_id, mobile, company_id, status, remark, create_time, update_time from company_voice_blacklist
    </sql>

    <select id="selectCompanyVoiceBlacklistList" parameterType="CompanyVoiceBlacklist" resultMap="CompanyVoiceBlacklistResult">
        <include refid="selectCompanyVoiceBlacklistVo"/>
        <where>  
            <if test="mobile != null  and mobile != ''"> and mobile = #{mobile}</if>
            <if test="companyId != null "> and company_id = #{companyId}</if>
            <if test="status != null "> and status = #{status}</if>
        </where>
        order by blacklist_id desc
    </select>
    
    <select id="selectCompanyVoiceBlacklistById" parameterType="Long" resultMap="CompanyVoiceBlacklistResult">
        <include refid="selectCompanyVoiceBlacklistVo"/>
        where blacklist_id = #{blacklistId}
    </select>
        
    <insert id="insertCompanyVoiceBlacklist" parameterType="CompanyVoiceBlacklist" useGeneratedKeys="true" keyProperty="blacklistId">
        insert into company_voice_blacklist
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="mobile != null">mobile,</if>
            <if test="companyId != null">company_id,</if>
            <if test="status != null">status,</if>
            <if test="remark != null">remark,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="mobile != null">#{mobile},</if>
            <if test="companyId != null">#{companyId},</if>
            <if test="status != null">#{status},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateCompanyVoiceBlacklist" parameterType="CompanyVoiceBlacklist">
        update company_voice_blacklist
        <trim prefix="SET" suffixOverrides=",">
            <if test="mobile != null">mobile = #{mobile},</if>
            <if test="companyId != null">company_id = #{companyId},</if>
            <if test="status != null">status = #{status},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where blacklist_id = #{blacklistId}
    </update>

    <delete id="deleteCompanyVoiceBlacklistById" parameterType="Long">
        delete from company_voice_blacklist where blacklist_id = #{blacklistId}
    </delete>

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