<?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.superdesk.uniorder.dao.mapper.channel.UnifiedChannelProfitXVirtMapper">
  <resultMap id="BaseResultMap" type="cn.superdesk.uniorder.dao.entity.channel.UnifiedChannelProfitXVirt">

    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="channel_id" jdbcType="BIGINT" property="channelId" />
    <result column="virt_id" jdbcType="BIGINT" property="virtId" />
    <result column="business_code" jdbcType="VARCHAR" property="businessCode" />
    <result column="proportion" jdbcType="DECIMAL" property="proportion" />
    <result column="beginDate" jdbcType="BIGINT" property="begindate" />
    <result column="endDate" jdbcType="BIGINT" property="enddate" />
  </resultMap>
  <sql id="Example_Where_Clause">

    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause">

    <where>
      <foreach collection="example.oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">

    id, channel_id, virt_id, business_code, proportion, beginDate, endDate
  </sql>
  <select id="selectByExample" parameterType="cn.superdesk.uniorder.dao.entity.channel.UnifiedChannelProfitXVirtExample" resultMap="BaseResultMap">

    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from unified_channel_profit_x_virt
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">

    select 
    <include refid="Base_Column_List" />
    from unified_channel_profit_x_virt
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">

    delete from unified_channel_profit_x_virt
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByExample" parameterType="cn.superdesk.uniorder.dao.entity.channel.UnifiedChannelProfitXVirtExample">

    delete from unified_channel_profit_x_virt
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="cn.superdesk.uniorder.dao.entity.channel.UnifiedChannelProfitXVirt">

    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into unified_channel_profit_x_virt (channel_id, virt_id, business_code, 
      proportion, beginDate, endDate
      )
    values (#{channelId,jdbcType=BIGINT}, #{virtId,jdbcType=BIGINT}, #{businessCode,jdbcType=VARCHAR}, 
      #{proportion,jdbcType=DECIMAL}, #{begindate,jdbcType=BIGINT}, #{enddate,jdbcType=BIGINT}
      )
  </insert>
  <insert id="insertSelective" parameterType="cn.superdesk.uniorder.dao.entity.channel.UnifiedChannelProfitXVirt">

    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into unified_channel_profit_x_virt
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="channelId != null">
        channel_id,
      </if>
      <if test="virtId != null">
        virt_id,
      </if>
      <if test="businessCode != null">
        business_code,
      </if>
      <if test="proportion != null">
        proportion,
      </if>
      <if test="begindate != null">
        beginDate,
      </if>
      <if test="enddate != null">
        endDate,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="channelId != null">
        #{channelId,jdbcType=BIGINT},
      </if>
      <if test="virtId != null">
        #{virtId,jdbcType=BIGINT},
      </if>
      <if test="businessCode != null">
        #{businessCode,jdbcType=VARCHAR},
      </if>
      <if test="proportion != null">
        #{proportion,jdbcType=DECIMAL},
      </if>
      <if test="begindate != null">
        #{begindate,jdbcType=BIGINT},
      </if>
      <if test="enddate != null">
        #{enddate,jdbcType=BIGINT},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="cn.superdesk.uniorder.dao.entity.channel.UnifiedChannelProfitXVirtExample" resultType="java.lang.Long">

    select count(*) from unified_channel_profit_x_virt
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">

    update unified_channel_profit_x_virt
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=BIGINT},
      </if>
      <if test="record.channelId != null">
        channel_id = #{record.channelId,jdbcType=BIGINT},
      </if>
      <if test="record.virtId != null">
        virt_id = #{record.virtId,jdbcType=BIGINT},
      </if>
      <if test="record.businessCode != null">
        business_code = #{record.businessCode,jdbcType=VARCHAR},
      </if>
      <if test="record.proportion != null">
        proportion = #{record.proportion,jdbcType=DECIMAL},
      </if>
      <if test="record.begindate != null">
        beginDate = #{record.begindate,jdbcType=BIGINT},
      </if>
      <if test="record.enddate != null">
        endDate = #{record.enddate,jdbcType=BIGINT},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">

    update unified_channel_profit_x_virt
    set id = #{record.id,jdbcType=BIGINT},
      channel_id = #{record.channelId,jdbcType=BIGINT},
      virt_id = #{record.virtId,jdbcType=BIGINT},
      business_code = #{record.businessCode,jdbcType=VARCHAR},
      proportion = #{record.proportion,jdbcType=DECIMAL},
      beginDate = #{record.begindate,jdbcType=BIGINT},
      endDate = #{record.enddate,jdbcType=BIGINT}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="cn.superdesk.uniorder.dao.entity.channel.UnifiedChannelProfitXVirt">

    update unified_channel_profit_x_virt
    <set>
      <if test="channelId != null">
        channel_id = #{channelId,jdbcType=BIGINT},
      </if>
      <if test="virtId != null">
        virt_id = #{virtId,jdbcType=BIGINT},
      </if>
      <if test="businessCode != null">
        business_code = #{businessCode,jdbcType=VARCHAR},
      </if>
      <if test="proportion != null">
        proportion = #{proportion,jdbcType=DECIMAL},
      </if>
      <if test="begindate != null">
        beginDate = #{begindate,jdbcType=BIGINT},
      </if>
      <if test="enddate != null">
        endDate = #{enddate,jdbcType=BIGINT},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="cn.superdesk.uniorder.dao.entity.channel.UnifiedChannelProfitXVirt">

    update unified_channel_profit_x_virt
    set channel_id = #{channelId,jdbcType=BIGINT},
      virt_id = #{virtId,jdbcType=BIGINT},
      business_code = #{businessCode,jdbcType=VARCHAR},
      proportion = #{proportion,jdbcType=DECIMAL},
      beginDate = #{begindate,jdbcType=BIGINT},
      endDate = #{enddate,jdbcType=BIGINT}
    where id = #{id,jdbcType=BIGINT}
  </update>
</mapper>