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

    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="channel_id" jdbcType="BIGINT" property="channelId" />
    <result column="channel_name" jdbcType="VARCHAR" property="channelName" />
    <result column="code" jdbcType="VARCHAR" property="code" />
    <result column="leader_name" jdbcType="VARCHAR" property="leaderName" />
    <result column="leader_phone" jdbcType="VARCHAR" property="leaderPhone" />
    <result column="leader_type" jdbcType="INTEGER" property="leaderType" />
    <result column="leader_wx_account" jdbcType="VARCHAR" property="leaderWxAccount" />
    <result column="address" jdbcType="VARCHAR" property="address" />
    <result column="remark" jdbcType="VARCHAR" property="remark" />
    <result column="company_type" jdbcType="TINYINT" property="companyType" />
    <result column="province_code" jdbcType="VARCHAR" property="provinceCode" />
    <result column="province_name" jdbcType="VARCHAR" property="provinceName" />
    <result column="city_code" jdbcType="VARCHAR" property="cityCode" />
    <result column="city_name" jdbcType="VARCHAR" property="cityName" />
    <result column="enabled" jdbcType="TINYINT" property="enabled" />
    <result column="sync_time" jdbcType="TIMESTAMP" property="syncTime" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="create_user_id" jdbcType="BIGINT" property="createUserId" />
    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
    <result column="update_user_id" jdbcType="BIGINT" property="updateUserId" />
  </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, channel_name, code, leader_name, leader_phone, leader_type, leader_wx_account, 
    address, remark, company_type, province_code, province_name, city_code, city_name, 
    enabled, sync_time, create_time, create_user_id, update_time, update_user_id
  </sql>
  <select id="selectByExample" parameterType="cn.superdesk.uniorder.dao.entity.channel.UnifiedChannelSyncExample" resultMap="BaseResultMap">

    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from unified_channel_sync
    <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_sync
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">

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

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

    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into unified_channel_sync (channel_id, channel_name, code, 
      leader_name, leader_phone, leader_type, 
      leader_wx_account, address, remark, 
      company_type, province_code, province_name, 
      city_code, city_name, enabled, 
      sync_time, create_time, create_user_id, 
      update_time, update_user_id)
    values (#{channelId,jdbcType=BIGINT}, #{channelName,jdbcType=VARCHAR}, #{code,jdbcType=VARCHAR}, 
      #{leaderName,jdbcType=VARCHAR}, #{leaderPhone,jdbcType=VARCHAR}, #{leaderType,jdbcType=INTEGER}, 
      #{leaderWxAccount,jdbcType=VARCHAR}, #{address,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, 
      #{companyType,jdbcType=TINYINT}, #{provinceCode,jdbcType=VARCHAR}, #{provinceName,jdbcType=VARCHAR}, 
      #{cityCode,jdbcType=VARCHAR}, #{cityName,jdbcType=VARCHAR}, #{enabled,jdbcType=TINYINT}, 
      #{syncTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP}, #{createUserId,jdbcType=BIGINT}, 
      #{updateTime,jdbcType=TIMESTAMP}, #{updateUserId,jdbcType=BIGINT})
  </insert>
  <insert id="insertSelective" parameterType="cn.superdesk.uniorder.dao.entity.channel.UnifiedChannelSync">

    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into unified_channel_sync
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="channelId != null">
        channel_id,
      </if>
      <if test="channelName != null">
        channel_name,
      </if>
      <if test="code != null">
        code,
      </if>
      <if test="leaderName != null">
        leader_name,
      </if>
      <if test="leaderPhone != null">
        leader_phone,
      </if>
      <if test="leaderType != null">
        leader_type,
      </if>
      <if test="leaderWxAccount != null">
        leader_wx_account,
      </if>
      <if test="address != null">
        address,
      </if>
      <if test="remark != null">
        remark,
      </if>
      <if test="companyType != null">
        company_type,
      </if>
      <if test="provinceCode != null">
        province_code,
      </if>
      <if test="provinceName != null">
        province_name,
      </if>
      <if test="cityCode != null">
        city_code,
      </if>
      <if test="cityName != null">
        city_name,
      </if>
      <if test="enabled != null">
        enabled,
      </if>
      <if test="syncTime != null">
        sync_time,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="createUserId != null">
        create_user_id,
      </if>
      <if test="updateTime != null">
        update_time,
      </if>
      <if test="updateUserId != null">
        update_user_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="channelId != null">
        #{channelId,jdbcType=BIGINT},
      </if>
      <if test="channelName != null">
        #{channelName,jdbcType=VARCHAR},
      </if>
      <if test="code != null">
        #{code,jdbcType=VARCHAR},
      </if>
      <if test="leaderName != null">
        #{leaderName,jdbcType=VARCHAR},
      </if>
      <if test="leaderPhone != null">
        #{leaderPhone,jdbcType=VARCHAR},
      </if>
      <if test="leaderType != null">
        #{leaderType,jdbcType=INTEGER},
      </if>
      <if test="leaderWxAccount != null">
        #{leaderWxAccount,jdbcType=VARCHAR},
      </if>
      <if test="address != null">
        #{address,jdbcType=VARCHAR},
      </if>
      <if test="remark != null">
        #{remark,jdbcType=VARCHAR},
      </if>
      <if test="companyType != null">
        #{companyType,jdbcType=TINYINT},
      </if>
      <if test="provinceCode != null">
        #{provinceCode,jdbcType=VARCHAR},
      </if>
      <if test="provinceName != null">
        #{provinceName,jdbcType=VARCHAR},
      </if>
      <if test="cityCode != null">
        #{cityCode,jdbcType=VARCHAR},
      </if>
      <if test="cityName != null">
        #{cityName,jdbcType=VARCHAR},
      </if>
      <if test="enabled != null">
        #{enabled,jdbcType=TINYINT},
      </if>
      <if test="syncTime != null">
        #{syncTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createUserId != null">
        #{createUserId,jdbcType=BIGINT},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateUserId != null">
        #{updateUserId,jdbcType=BIGINT},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="cn.superdesk.uniorder.dao.entity.channel.UnifiedChannelSyncExample" resultType="java.lang.Long">

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

    update unified_channel_sync
    <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.channelName != null">
        channel_name = #{record.channelName,jdbcType=VARCHAR},
      </if>
      <if test="record.code != null">
        code = #{record.code,jdbcType=VARCHAR},
      </if>
      <if test="record.leaderName != null">
        leader_name = #{record.leaderName,jdbcType=VARCHAR},
      </if>
      <if test="record.leaderPhone != null">
        leader_phone = #{record.leaderPhone,jdbcType=VARCHAR},
      </if>
      <if test="record.leaderType != null">
        leader_type = #{record.leaderType,jdbcType=INTEGER},
      </if>
      <if test="record.leaderWxAccount != null">
        leader_wx_account = #{record.leaderWxAccount,jdbcType=VARCHAR},
      </if>
      <if test="record.address != null">
        address = #{record.address,jdbcType=VARCHAR},
      </if>
      <if test="record.remark != null">
        remark = #{record.remark,jdbcType=VARCHAR},
      </if>
      <if test="record.companyType != null">
        company_type = #{record.companyType,jdbcType=TINYINT},
      </if>
      <if test="record.provinceCode != null">
        province_code = #{record.provinceCode,jdbcType=VARCHAR},
      </if>
      <if test="record.provinceName != null">
        province_name = #{record.provinceName,jdbcType=VARCHAR},
      </if>
      <if test="record.cityCode != null">
        city_code = #{record.cityCode,jdbcType=VARCHAR},
      </if>
      <if test="record.cityName != null">
        city_name = #{record.cityName,jdbcType=VARCHAR},
      </if>
      <if test="record.enabled != null">
        enabled = #{record.enabled,jdbcType=TINYINT},
      </if>
      <if test="record.syncTime != null">
        sync_time = #{record.syncTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.createTime != null">
        create_time = #{record.createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.createUserId != null">
        create_user_id = #{record.createUserId,jdbcType=BIGINT},
      </if>
      <if test="record.updateTime != null">
        update_time = #{record.updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.updateUserId != null">
        update_user_id = #{record.updateUserId,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_sync
    set id = #{record.id,jdbcType=BIGINT},
      channel_id = #{record.channelId,jdbcType=BIGINT},
      channel_name = #{record.channelName,jdbcType=VARCHAR},
      code = #{record.code,jdbcType=VARCHAR},
      leader_name = #{record.leaderName,jdbcType=VARCHAR},
      leader_phone = #{record.leaderPhone,jdbcType=VARCHAR},
      leader_type = #{record.leaderType,jdbcType=INTEGER},
      leader_wx_account = #{record.leaderWxAccount,jdbcType=VARCHAR},
      address = #{record.address,jdbcType=VARCHAR},
      remark = #{record.remark,jdbcType=VARCHAR},
      company_type = #{record.companyType,jdbcType=TINYINT},
      province_code = #{record.provinceCode,jdbcType=VARCHAR},
      province_name = #{record.provinceName,jdbcType=VARCHAR},
      city_code = #{record.cityCode,jdbcType=VARCHAR},
      city_name = #{record.cityName,jdbcType=VARCHAR},
      enabled = #{record.enabled,jdbcType=TINYINT},
      sync_time = #{record.syncTime,jdbcType=TIMESTAMP},
      create_time = #{record.createTime,jdbcType=TIMESTAMP},
      create_user_id = #{record.createUserId,jdbcType=BIGINT},
      update_time = #{record.updateTime,jdbcType=TIMESTAMP},
      update_user_id = #{record.updateUserId,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.UnifiedChannelSync">

    update unified_channel_sync
    <set>
      <if test="channelId != null">
        channel_id = #{channelId,jdbcType=BIGINT},
      </if>
      <if test="channelName != null">
        channel_name = #{channelName,jdbcType=VARCHAR},
      </if>
      <if test="code != null">
        code = #{code,jdbcType=VARCHAR},
      </if>
      <if test="leaderName != null">
        leader_name = #{leaderName,jdbcType=VARCHAR},
      </if>
      <if test="leaderPhone != null">
        leader_phone = #{leaderPhone,jdbcType=VARCHAR},
      </if>
      <if test="leaderType != null">
        leader_type = #{leaderType,jdbcType=INTEGER},
      </if>
      <if test="leaderWxAccount != null">
        leader_wx_account = #{leaderWxAccount,jdbcType=VARCHAR},
      </if>
      <if test="address != null">
        address = #{address,jdbcType=VARCHAR},
      </if>
      <if test="remark != null">
        remark = #{remark,jdbcType=VARCHAR},
      </if>
      <if test="companyType != null">
        company_type = #{companyType,jdbcType=TINYINT},
      </if>
      <if test="provinceCode != null">
        province_code = #{provinceCode,jdbcType=VARCHAR},
      </if>
      <if test="provinceName != null">
        province_name = #{provinceName,jdbcType=VARCHAR},
      </if>
      <if test="cityCode != null">
        city_code = #{cityCode,jdbcType=VARCHAR},
      </if>
      <if test="cityName != null">
        city_name = #{cityName,jdbcType=VARCHAR},
      </if>
      <if test="enabled != null">
        enabled = #{enabled,jdbcType=TINYINT},
      </if>
      <if test="syncTime != null">
        sync_time = #{syncTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createUserId != null">
        create_user_id = #{createUserId,jdbcType=BIGINT},
      </if>
      <if test="updateTime != null">
        update_time = #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateUserId != null">
        update_user_id = #{updateUserId,jdbcType=BIGINT},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="cn.superdesk.uniorder.dao.entity.channel.UnifiedChannelSync">

    update unified_channel_sync
    set channel_id = #{channelId,jdbcType=BIGINT},
      channel_name = #{channelName,jdbcType=VARCHAR},
      code = #{code,jdbcType=VARCHAR},
      leader_name = #{leaderName,jdbcType=VARCHAR},
      leader_phone = #{leaderPhone,jdbcType=VARCHAR},
      leader_type = #{leaderType,jdbcType=INTEGER},
      leader_wx_account = #{leaderWxAccount,jdbcType=VARCHAR},
      address = #{address,jdbcType=VARCHAR},
      remark = #{remark,jdbcType=VARCHAR},
      company_type = #{companyType,jdbcType=TINYINT},
      province_code = #{provinceCode,jdbcType=VARCHAR},
      province_name = #{provinceName,jdbcType=VARCHAR},
      city_code = #{cityCode,jdbcType=VARCHAR},
      city_name = #{cityName,jdbcType=VARCHAR},
      enabled = #{enabled,jdbcType=TINYINT},
      sync_time = #{syncTime,jdbcType=TIMESTAMP},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      create_user_id = #{createUserId,jdbcType=BIGINT},
      update_time = #{updateTime,jdbcType=TIMESTAMP},
      update_user_id = #{updateUserId,jdbcType=BIGINT}
    where id = #{id,jdbcType=BIGINT}
  </update>
</mapper>