<?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.CompanyVoiceMobileMapper">
    
    <resultMap type="CompanyVoiceMobile" id="CompanyVoiceMobileResult">
        <result property="mobileId"    column="mobile_id"    />
        <result property="apiId"    column="api_id"    />
        <result property="mobile"    column="mobile"    />
        <result property="status"    column="status"    />
        <result property="companyId"    column="company_id"    />
        <result property="mobileType"    column="mobile_type"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectCompanyVoiceMobileVo">
        select mobile_id, api_id, mobile, status,company_id,mobile_type,remark from company_voice_mobile
    </sql>

    <select id="selectCompanyVoiceMobileList" parameterType="CompanyVoiceMobile" resultMap="CompanyVoiceMobileResult">
        <include refid="selectCompanyVoiceMobileVo"/>
        <where>  
            <if test="apiId != null "> and api_id = #{apiId}</if>
            <if test="mobile != null  and mobile != ''"> and mobile = #{mobile}</if>
            <if test="status != null "> and status = #{status}</if>
        </where>
    </select>
    
    <select id="selectCompanyVoiceMobileById" parameterType="Long" resultMap="CompanyVoiceMobileResult">
        <include refid="selectCompanyVoiceMobileVo"/>
        where mobile_id = #{mobileId}
    </select>
        
    <insert id="insertCompanyVoiceMobile" parameterType="CompanyVoiceMobile">
        insert into company_voice_mobile
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="mobileId != null">mobile_id,</if>
            <if test="apiId != null">api_id,</if>
            <if test="mobile != null">mobile,</if>
            <if test="status != null">status,</if>
            <if test="companyId != null">company_id,</if>
            <if test="mobileType != null">mobile_type,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="mobileId != null">#{mobileId},</if>
            <if test="apiId != null">#{apiId},</if>
            <if test="mobile != null">#{mobile},</if>
            <if test="status != null">#{status},</if>
            <if test="companyId != null">#{companyId},</if>
            <if test="mobileType != null">#{mobileType},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateCompanyVoiceMobile" parameterType="CompanyVoiceMobile">
        update company_voice_mobile
        <trim prefix="SET" suffixOverrides=",">
            <if test="apiId != null">api_id = #{apiId},</if>
            <if test="mobile != null">mobile = #{mobile},</if>
            <if test="status != null">status = #{status},</if>
            <if test="companyId != null">company_id = #{companyId},</if>
            <if test="mobileType != null">mobile_type = #{mobileType},</if>
            <if test="remark != null">remark = #{remark},</if>

        </trim>
        where mobile_id = #{mobileId}
    </update>

    <delete id="deleteCompanyVoiceMobileById" parameterType="Long">
        delete from company_voice_mobile where mobile_id = #{mobileId}
    </delete>

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