<?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.SpMmsChannelConfigMapper">
  <resultMap id="BaseResultMap" type="MmsChannelConfig">
    <id column="ID" jdbcType="INTEGER" property="id" />
    <result column="OPERTOR_TYPE" jdbcType="INTEGER" property="opertorType" />
    <result column="CHANNELID" jdbcType="INTEGER" property="channelId" />
    <result column="SP_ID" jdbcType="INTEGER" property="spId" />
    <result column="CHANNEL_GROUP" jdbcType="INTEGER" property="channelGroup" />
    <result column="CREATETIME" jdbcType="TIMESTAMP" property="createtime" />
  </resultMap>
  <sql id="Base_Column_List">
    ID, OPERTOR_TYPE, CHANNELID, SP_ID,CHANNEL_GROUP, CREATETIME
  </sql>
  <select id="getMmsChannelConfigInfo" parameterType="MmsChannelConfig" resultMap="BaseResultMap">
    select
    cg.id id,
    cg.opertor_type opertorType,
    cg.channelId channelId,
    cg.sp_id spId,
    cg.createtime,
    cg.channel_group channelGroup
    from mms_sp_channel_config cg
    where 1=1
    <if test="id != null and id>0">
      and cg.id = #{id}
    </if>
    <if test="channelId != null and channelId>0">
      and cg.channelId = #{channelId}
    </if>
    <if test="spId!=null and spId>0">
      and cg.sp_id = #{spId}
    </if>
    <if test="opertorType != null and opertorType > 0 ">
      and cg.opertor_type = #{opertorType}
    </if>
    <if test="channelGroup != null and channelGroup > 0 ">
      and cg.channel_group = #{channelGroup}
    </if>
  </select>
  <select id="listMmsChannelConfig" parameterType="int" resultMap="BaseResultMap">
    select
    cg.id id,
    cg.opertor_type opertorType,
    cg.channelId channelId,
    cg.sp_id spId,
    cg.channel_group channelGroup,
    cg.createtime
    from mms_sp_channel_config cg
    and cg.sp_id = #{spId}
  </select>
  <delete id="deleteSpMmsChannel" parameterType="int">
    delete from  mms_sp_channel_config where sp_id=#{spId}
  </delete>
  <insert id="insertMmsChannelConfig"   useGeneratedKeys="true" keyProperty="id" parameterType="MmsChannelConfig" >
    insert into mms_sp_channel_config  (opertor_type,channelId,sp_id,channel_group,createtime) values (#{opertorType},#{channelId},#{spId},#{channelGroup},sysdate())
  </insert>


</mapper>