<?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="cn.roadm.mapper.PaInfoMapper">

    <select id="getSpChannelConfigById" parameterType="int" resultType="SpChannelConfig">
        select * from sms_sp_channel_config g where g.spId = #{spId}
    </select>
    
    <update id="updateSpChannelConfig" parameterType="SpChannelConfig">
        update sms_sp_channel_config
        <set>
            <if test = "network != null">
                network = #{network, network=VARCHAR},
            </if>
            <if test = "type != null">
                type = #{type, type=VARCHAR},
            </if>
            <if test = "spId != null">
                spId = #{spId, spId=VARCHAR},
            </if>
            <if test = "mobile != null">
                mobile = #{mobile, mobile=VARCHAR},
            </if>
            <if test = "unicom != null">
                unicom = #{unicom, unicom=VARCHAR},
            </if>
            <if test = "telecom != null">
                telecom = #{telecom, telecom=VARCHAR},
            </if>
            <if test = "mobileGroup != null">
                mobileGroup = #{mobileGroup, mobileGroup=VARCHAR},
            </if>
            <if test = "unicomGroup != null">
                unicomGroup = #{unicomGroup, unicomGroup=VARCHAR},
            </if>
            <if test = "telecomGroup != null">
                telecomGroup = #{telecomGroup, telecomGroup=VARCHAR},
            </if>
            <if test = "internation != null">
                internation = #{internation, telecomGroup=VARCHAR},
            </if>
        </set>
        where id = #{id, jdbcType=INTEGER}
    </update>
    
     <!--企业通道配置-->
    <insert id="insertSpChannelConfig" useGeneratedKeys="true" keyProperty="id" parameterType="SpChannelConfig">
    insert into sms_sp_channel_config
    <trim prefix="(" suffix=")" suffixOverrides=",">
        <if test = "network != '' and network!=null">
            network,
        </if>
        <if test = "type != '' and type!=null">
            type,
        </if>
        <if test = "spId != '' and spId!=null">
            spId,
        </if>
        <if test = "mobile != '' and mobile!=null">
            mobile,
        </if>
        <if test = "unicom != '' and unicom!=null">
            unicom,
        </if>
        <if test = "telecom != '' and telecom!=null">
            telecom,
        </if>
        <if test = "mobileGroup != '' and mobileGroup!=null">
            mobileGroup,
        </if>
        <if test = "unicomGroup != '' and unicomGroup!=null">
            unicomGroup,
        </if>
        <if test = "telecomGroup != '' and telecomGroup!=null">
            telecomGroup,
        </if>
        <if test = "internation != '' and internation">
            internation,
        </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
        <if test = "network != null and network != ''">
            #{network, network=VARCHAR},
        </if>
        <if test = "type != null and type != ''">
            #{type, type=VARCHAR},
        </if>
        <if test = "spId != null and spId != ''">
            #{spId, spId=VARCHAR},
        </if>
        <if test = "mobile != null and mobile != '' ">
            #{mobile, mobile=VARCHAR},
        </if>
        <if test = "unicom != null and unicom != '' " >
            #{unicom, unicom=VARCHAR},
        </if>
        <if test = "telecom != null and telecom != '' ">
            #{telecom, telecom=VARCHAR},
        </if>
        <if test = "mobileGroup != null and  mobileGroup != ''">
            #{mobileGroup, mobileGroup=VARCHAR},
        </if>
        <if test = "unicomGroup != null and unicomGroup != ''">
            #{unicomGroup, unicomGroup=VARCHAR},
        </if>
        <if test = "telecomGroup != null and telecomGroup != ''">
            #{telecomGroup, telecomGroup=VARCHAR},
        </if>
        <if test = "internation != null and internation != '' ">
            #{internation, internation=VARCHAR},
        </if>
        
    </trim>
</insert>
    
</mapper>
