<?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.MmsChannelInfoMapper">
  <resultMap id="BaseResultMap" type="MmsChannelInfo">
    <id column="ID" jdbcType="INTEGER" property="id" />
    <result column="CHANNEL_NAME" jdbcType="VARCHAR" property="channelName" />
    <result column="STATUS" jdbcType="VARCHAR" property="status" />
    <result column="IS_SUPPORT_UNICOM" jdbcType="INTEGER" property="isSupportUnicom" />
    <result column="IS_SUPPORT_MOBILE" jdbcType="INTEGER" property="isSupportMobile" />
    <result column="IS_SUPPORT_TELECOM" jdbcType="INTEGER" property="isSupportTelecom" />
    <result column="MOBILE_PREFIX" jdbcType="VARCHAR" property="mobilePrefix" />
    <result column="UNICOM_PREFIX" jdbcType="VARCHAR" property="unicomPrefix" />
    <result column="TELECOM_PREFIX" jdbcType="VARCHAR" property="telecomPrefix" />
    <result column="IS_MOBILE_EXTEND" jdbcType="INTEGER" property="isMobileExtend" />
    <result column="IS_UNICOM_EXTEND" jdbcType="INTEGER" property="isUnicomExtend" />
    <result column="IS_TELECOM_EXTEND" jdbcType="INTEGER" property="isTelecomExtend" />
    <result column="CH_DESC" jdbcType="VARCHAR" property="chDesc" />
    <result column="PA_URL" jdbcType="VARCHAR" property="paUrl" />
    <result column="PA_LOCATION" jdbcType="INTEGER" property="paLocation" />
    <result column="LOGINNAME" jdbcType="VARCHAR" property="loginname" />
    <result column="PASSWORD" jdbcType="VARCHAR" property="password" />
    <result column="ACCESSNUMBER" jdbcType="VARCHAR" property="accessnumber" />
    <result column="IP" jdbcType="VARCHAR" property="ip" />
    <result column="PORT" jdbcType="VARCHAR" property="port" />
    <result column="CARRIER_SPEED" jdbcType="VARCHAR" property="carrierSpeed" />
    <result column="CARRIER_SP_SIGN" jdbcType="VARCHAR" property="carrierSpSign" />
    <result column="PROTOCOL_TYPE" jdbcType="VARCHAR" property="protocolType" />
    <result column="SUPPLIER_NAME" jdbcType="VARCHAR" property="supplierName" />
    <result column="COOPERATE_COMPANY" jdbcType="VARCHAR" property="cooperateCompany" />
    <result column="ATTRACT_LIMIT" jdbcType="INTEGER" property="attractLimit" />
    <result column="LINK_PROPERTIES" jdbcType="INTEGER" property="linkProperties" />
  </resultMap>
  <sql id="Base_Column_List">
    ID, CHANNEL_NAME, STATUS, IS_SUPPORT_UNICOM, IS_SUPPORT_MOBILE, IS_SUPPORT_TELECOM,
    MOBILE_PREFIX, UNICOM_PREFIX, TELECOM_PREFIX, IS_MOBILE_EXTEND, IS_UNICOM_EXTEND,
    IS_TELECOM_EXTEND, CH_DESC, PA_URL, PA_LOCATION,LOGINNAME,PASSWORD,accessnumber,IP,
    PORT,CARRIER_SPEED,CARRIER_SP_SIGN,PROTOCOL_TYPE,http_response,access_key,`desc`,
    ATTRACT_LIMIT,LINK_PROPERTIES
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from mms_send_channel_info
    where ID = #{id,jdbcType=INTEGER}
  </select>
  <select id="getMmsChannelInfoById" parameterType="int" resultMap="BaseResultMap">
      select
      <include refid="Base_Column_List" />
      from mms_send_channel_info sc
         where sc.status=1
      and sc.id = #{channelId}
  </select>
  <select id="listPageMmsChannelInfo" parameterType="int" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from mms_send_channel_info sc
    <where>
      sc.protocol_type &lt; 20
      <if test="status != null and status != '' and status != -1">
        and sc.status=#{status}
      </if>
      <if test="channelName != null and channelName != ''">
        and sc.channel_name LIKE CONCAT('%',#{channelName},'%')
      </if>
      <if test="isSupportUnicom!=null and isSupportUnicom>0">
        and sc.is_support_unicom = #{isSupportUnicom}
      </if>
      <if test="isSupportMobile!=null and isSupportMobile>0">
        and sc.is_support_mobile = #{isSupportMobile}
      </if>
      <if test="isSupportTelecom!=null and isSupportTelecom>0">
        and sc.is_support_telecom = #{isSupportTelecom}
      </if>
    </where>
  </select>
  <select id="selectTemplateDefaultVarByChannelId" resultType="String">
    select a.templateDefaultVar from mms_http_channel_template a right join  mms_http_channel_template_config b
    on a.templateCode = b.templateCode where b.channelid = #{channelId}
  </select>
  <select id="listAllMmsChannelInfo" parameterType="int" resultMap="BaseResultMap">
    select
    sc.ID, sc.CHANNEL_NAME, sc.STATUS, sc.IS_SUPPORT_UNICOM, sc.IS_SUPPORT_MOBILE, sc.IS_SUPPORT_TELECOM,
    sc.MOBILE_PREFIX, sc.UNICOM_PREFIX, sc.TELECOM_PREFIX, sc.IS_MOBILE_EXTEND, sc.IS_UNICOM_EXTEND,
    sc.IS_TELECOM_EXTEND, sc.CH_DESC, sc.PA_URL, sc.PA_LOCATION,sc.LOGINNAME,sc.PASSWORD,sc.accessnumber,sc.IP,
    sc.PORT,sc.CARRIER_SPEED,sc.CARRIER_SP_SIGN,sc.PROTOCOL_TYPE,sc.http_response,sc.access_key,sc.`desc`,
    sc.COOPERATE_COMPANY, sc.ATTRACT_LIMIT, sc.LINK_PROPERTIES,
    cs.SUPPLIER_NAME
    from mms_send_channel_info sc
    LEFT JOIN channel_supplier cs ON sc.supplier_id = cs.id
    <where>
        <if test="status != null and status != '' and status != -1">
          and sc.status=#{status}
        </if>
        <if test="channelName != null and channelName != ''">
          and sc.channel_name LIKE CONCAT('%',#{channelName},'%')
        </if>
        <if test="isSupportUnicom!=null and isSupportUnicom>0">
          and sc.is_support_unicom = #{isSupportUnicom}
        </if>
        <if test="isSupportMobile!=null and isSupportMobile>0">
          and sc.is_support_mobile = #{isSupportMobile}
        </if>
        <if test="isSupportTelecom!=null and isSupportTelecom>0">
          and sc.is_support_telecom = #{isSupportTelecom}
        </if>
    </where>

  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from mms_send_channel_info
    where ID = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="MmsChannelInfo">
    insert into mms_send_channel_info (ID, CHANNEL_NAME, STATUS,
      IS_SUPPORT_UNICOM, IS_SUPPORT_MOBILE, IS_SUPPORT_TELECOM,
      MOBILE_PREFIX, UNICOM_PREFIX, TELECOM_PREFIX,
      IS_MOBILE_EXTEND, IS_UNICOM_EXTEND, IS_TELECOM_EXTEND,
      CH_DESC, PA_URL, PA_LOCATION,LOGINNAME,PASSWORD,ACCESSNUMBER,IP,
    PORT,CARRIER_SPEED,CARRIER_SP_SIGN,PROTOCOL_TYPE,http_response,access_key,
                                       ATTRACT_LIMIT,LINK_PROPERTIES
      )
    values (#{id,jdbcType=INTEGER}, #{channelName,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR},
      #{isSupportUnicom,jdbcType=INTEGER}, #{isSupportMobile,jdbcType=INTEGER}, #{isSupportTelecom,jdbcType=INTEGER},
      #{mobilePrefix,jdbcType=VARCHAR}, #{unicomPrefix,jdbcType=VARCHAR}, #{telecomPrefix,jdbcType=VARCHAR},
      #{isMobileExtend,jdbcType=INTEGER}, #{isUnicomExtend,jdbcType=INTEGER}, #{isTelecomExtend,jdbcType=INTEGER},
      #{chDesc,jdbcType=VARCHAR}, #{paUrl,jdbcType=VARCHAR}, #{paLocation,jdbcType=INTEGER},#{loginname},#{password},
      #{accessnumber},#{ip},#{port},#{carrierSpeed},#{carrierSpSign},#{protocolType}
      , #{http_response,jdbcType=VARCHAR}, #{access_key,jdbcType=VARCHAR},
      #{attractLimit,jdbcType=INTEGER}, #{linkProperties,jdbcType=INTEGER}
      )
  </insert>

  <update id="updateByPrimaryKey" parameterType="MmsChannelInfo">
    update mms_send_channel_info
    <set>
      <if test="channelName != null">
        CHANNEL_NAME = #{channelName,jdbcType=VARCHAR},
      </if>
      <if test="status != null">
        STATUS = #{status,jdbcType=VARCHAR},
      </if>
      <if test="isSupportUnicom != null">
        IS_SUPPORT_UNICOM = #{isSupportUnicom,jdbcType=INTEGER},
      </if>
      <if test="isSupportMobile != null">
        IS_SUPPORT_MOBILE = #{isSupportMobile,jdbcType=INTEGER},
      </if>
      <if test="isSupportTelecom != null">
        IS_SUPPORT_TELECOM = #{isSupportTelecom,jdbcType=INTEGER},
      </if>
      <if test="mobilePrefix != null">
        MOBILE_PREFIX = #{mobilePrefix,jdbcType=VARCHAR},
      </if>
      <if test="unicomPrefix != null">
        UNICOM_PREFIX = #{unicomPrefix,jdbcType=VARCHAR},
      </if>
      <if test="telecomPrefix != null">
        TELECOM_PREFIX = #{telecomPrefix,jdbcType=VARCHAR},
      </if>
      <if test="isMobileExtend != null">
        IS_MOBILE_EXTEND = #{isMobileExtend,jdbcType=INTEGER},
      </if>
      <if test="isUnicomExtend != null">
        IS_UNICOM_EXTEND = #{isUnicomExtend,jdbcType=INTEGER},
      </if>
      <if test="isTelecomExtend != null">
        IS_TELECOM_EXTEND = #{isTelecomExtend,jdbcType=INTEGER},
      </if>
      <if test="chDesc != null">
        CH_DESC = #{chDesc,jdbcType=VARCHAR},
      </if>
      <if test="paUrl != null">
        PA_URL = #{paUrl,jdbcType=VARCHAR},
      </if>
      <if test="paLocation != null">
        PA_LOCATION = #{paLocation,jdbcType=INTEGER},
      </if>
      <if test="loginname != null">
        LOGINNAME = #{loginname,jdbcType=VARCHAR},
      </if>
      <if test="password != null">
        PASSWORD = #{password,jdbcType=VARCHAR},
      </if>
      <if test="accessnumber != null">
        ACCESSNUMBER = #{accessnumber,jdbcType=VARCHAR},
      </if>
      <if test="ip != null">
        IP = #{ip,jdbcType=VARCHAR},
      </if>
      <if test="port != null">
        PORT = #{port,jdbcType=VARCHAR},
      </if>
      <if test="carrierSpeed != null">
        CARRIER_SPEED = #{carrierSpeed,jdbcType=VARCHAR},
      </if>
      <if test="carrierSpSign != null">
        CARRIER_SP_SIGN = #{carrierSpSign,jdbcType=VARCHAR},
      </if>
      <if test="protocolType != null">
        PROTOCOL_TYPE = #{protocolType,jdbcType=VARCHAR},
      </if>
      <if test="access_key != null and access_key!=''">
      		access_key = #{access_key,jdbcType=VARCHAR},
      </if>
     <if test="http_response != null and http_response!=''">
     	http_response = #{http_response,jdbcType=VARCHAR},
     </if>
     <if test="attractLimit != null">
       ATTRACT_LIMIT = #{attractLimit,jdbcType=INTEGER},
     </if>
     <if test="linkProperties != null">
       LINK_PROPERTIES = #{linkProperties,jdbcType=INTEGER},
     </if>
    </set>
    where ID = #{id,jdbcType=INTEGER}
  </update>

  <select id="getHttpChannelOptions" resultType="cn.roadm.bo.PageSelectOptionsVO">
    select id as value, channel_name as label from sms_send_channel_info where STATUS = '1' and protocol_type = '4'
  </select>
</mapper>
