<?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.operationCenter.OperationCenterOperatorsMapper">
  <resultMap id="BaseResultMap" type="cn.superdesk.uniorder.dao.entity.operationCenter.UnifiedOperators">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="biz_platform_code" jdbcType="VARCHAR" property="bizPlatformCode" />
    <result column="biz_platform_name" jdbcType="VARCHAR" property="bizPlatformName" />
    <result column="biz_operator_code" jdbcType="VARCHAR" property="bizOperatorCode" />
    <result column="biz_operator_id" jdbcType="VARCHAR" property="bizOperatorId" />
    <result column="contact" jdbcType="VARCHAR" property="contact" />
    <result column="mobile" jdbcType="VARCHAR" property="mobile" />
    <result column="address" jdbcType="VARCHAR" property="address" />
    <result column="remark" jdbcType="VARCHAR" property="remark" />
    <result column="longitude" jdbcType="VARCHAR" property="longitude" />
    <result column="latitude" jdbcType="VARCHAR" property="latitude" />
    <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" />
    <result column="deleted" jdbcType="TINYINT" property="deleted" />
  </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, name, biz_platform_code, biz_platform_name, biz_operator_code, biz_operator_id, 
    contact, mobile, address, remark, longitude, latitude, create_time, create_user_id, 
    update_time, update_user_id, deleted
  </sql>
  <select id="selectByExample" parameterType="cn.superdesk.uniorder.dao.entity.operationCenter.OperationCenterOperatorsExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from unified_operators
    <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_operators
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from unified_operators
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByExample" parameterType="cn.superdesk.uniorder.dao.entity.operationCenter.OperationCenterOperatorsExample">
    delete from unified_operators
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="cn.superdesk.uniorder.dao.entity.operationCenter.UnifiedOperators">
    insert into unified_operators (id, name, biz_platform_code, 
      biz_platform_name, biz_operator_code, biz_operator_id, 
      contact, mobile, address, 
      remark, longitude, latitude, 
      create_time, create_user_id, update_time, 
      update_user_id, deleted)
    values (#{id,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{bizPlatformCode,jdbcType=VARCHAR}, 
      #{bizPlatformName,jdbcType=VARCHAR}, #{bizOperatorCode,jdbcType=VARCHAR}, #{bizOperatorId,jdbcType=VARCHAR}, 
      #{contact,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR}, #{address,jdbcType=VARCHAR}, 
      #{remark,jdbcType=VARCHAR}, #{longitude,jdbcType=VARCHAR}, #{latitude,jdbcType=VARCHAR}, 
      #{createTime,jdbcType=TIMESTAMP}, #{createUserId,jdbcType=BIGINT}, #{updateTime,jdbcType=TIMESTAMP}, 
      #{updateUserId,jdbcType=BIGINT}, #{deleted,jdbcType=TINYINT})
  </insert>
  <insert id="insertSelective" parameterType="cn.superdesk.uniorder.dao.entity.operationCenter.UnifiedOperators">
    insert into unified_operators
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="name != null">
        name,
      </if>
      <if test="bizPlatformCode != null">
        biz_platform_code,
      </if>
      <if test="bizPlatformName != null">
        biz_platform_name,
      </if>
      <if test="bizOperatorCode != null">
        biz_operator_code,
      </if>
      <if test="bizOperatorId != null">
        biz_operator_id,
      </if>
      <if test="contact != null">
        contact,
      </if>
      <if test="mobile != null">
        mobile,
      </if>
      <if test="address != null">
        address,
      </if>
      <if test="remark != null">
        remark,
      </if>
      <if test="longitude != null">
        longitude,
      </if>
      <if test="latitude != null">
        latitude,
      </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>
      <if test="deleted != null">
        deleted,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=BIGINT},
      </if>
      <if test="name != null">
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="bizPlatformCode != null">
        #{bizPlatformCode,jdbcType=VARCHAR},
      </if>
      <if test="bizPlatformName != null">
        #{bizPlatformName,jdbcType=VARCHAR},
      </if>
      <if test="bizOperatorCode != null">
        #{bizOperatorCode,jdbcType=VARCHAR},
      </if>
      <if test="bizOperatorId != null">
        #{bizOperatorId,jdbcType=VARCHAR},
      </if>
      <if test="contact != null">
        #{contact,jdbcType=VARCHAR},
      </if>
      <if test="mobile != null">
        #{mobile,jdbcType=VARCHAR},
      </if>
      <if test="address != null">
        #{address,jdbcType=VARCHAR},
      </if>
      <if test="remark != null">
        #{remark,jdbcType=VARCHAR},
      </if>
      <if test="longitude != null">
        #{longitude,jdbcType=VARCHAR},
      </if>
      <if test="latitude != null">
        #{latitude,jdbcType=VARCHAR},
      </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>
      <if test="deleted != null">
        #{deleted,jdbcType=TINYINT},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="cn.superdesk.uniorder.dao.entity.operationCenter.OperationCenterOperatorsExample" resultType="java.lang.Long">
    select count(*) from unified_operators
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update unified_operators
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=BIGINT},
      </if>
      <if test="record.name != null">
        name = #{record.name,jdbcType=VARCHAR},
      </if>
      <if test="record.bizPlatformCode != null">
        biz_platform_code = #{record.bizPlatformCode,jdbcType=VARCHAR},
      </if>
      <if test="record.bizPlatformName != null">
        biz_platform_name = #{record.bizPlatformName,jdbcType=VARCHAR},
      </if>
      <if test="record.bizOperatorCode != null">
        biz_operator_code = #{record.bizOperatorCode,jdbcType=VARCHAR},
      </if>
      <if test="record.bizOperatorId != null">
        biz_operator_id = #{record.bizOperatorId,jdbcType=VARCHAR},
      </if>
      <if test="record.contact != null">
        contact = #{record.contact,jdbcType=VARCHAR},
      </if>
      <if test="record.mobile != null">
        mobile = #{record.mobile,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.longitude != null">
        longitude = #{record.longitude,jdbcType=VARCHAR},
      </if>
      <if test="record.latitude != null">
        latitude = #{record.latitude,jdbcType=VARCHAR},
      </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>
      <if test="record.deleted != null">
        deleted = #{record.deleted,jdbcType=TINYINT},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update unified_operators
    set id = #{record.id,jdbcType=BIGINT},
      name = #{record.name,jdbcType=VARCHAR},
      biz_platform_code = #{record.bizPlatformCode,jdbcType=VARCHAR},
      biz_platform_name = #{record.bizPlatformName,jdbcType=VARCHAR},
      biz_operator_code = #{record.bizOperatorCode,jdbcType=VARCHAR},
      biz_operator_id = #{record.bizOperatorId,jdbcType=VARCHAR},
      contact = #{record.contact,jdbcType=VARCHAR},
      mobile = #{record.mobile,jdbcType=VARCHAR},
      address = #{record.address,jdbcType=VARCHAR},
      remark = #{record.remark,jdbcType=VARCHAR},
      longitude = #{record.longitude,jdbcType=VARCHAR},
      latitude = #{record.latitude,jdbcType=VARCHAR},
      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},
      deleted = #{record.deleted,jdbcType=TINYINT}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="cn.superdesk.uniorder.dao.entity.operationCenter.UnifiedOperators">
    update unified_operators
    <set>
      <if test="name != null">
        name = #{name,jdbcType=VARCHAR},
      </if>
      <if test="bizPlatformCode != null">
        biz_platform_code = #{bizPlatformCode,jdbcType=VARCHAR},
      </if>
      <if test="bizPlatformName != null">
        biz_platform_name = #{bizPlatformName,jdbcType=VARCHAR},
      </if>
      <if test="bizOperatorCode != null">
        biz_operator_code = #{bizOperatorCode,jdbcType=VARCHAR},
      </if>
      <if test="bizOperatorId != null">
        biz_operator_id = #{bizOperatorId,jdbcType=VARCHAR},
      </if>
      <if test="contact != null">
        contact = #{contact,jdbcType=VARCHAR},
      </if>
      <if test="mobile != null">
        mobile = #{mobile,jdbcType=VARCHAR},
      </if>
      <if test="address != null">
        address = #{address,jdbcType=VARCHAR},
      </if>
      <if test="remark != null">
        remark = #{remark,jdbcType=VARCHAR},
      </if>
      <if test="longitude != null">
        longitude = #{longitude,jdbcType=VARCHAR},
      </if>
      <if test="latitude != null">
        latitude = #{latitude,jdbcType=VARCHAR},
      </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>
      <if test="deleted != null">
        deleted = #{deleted,jdbcType=TINYINT},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="cn.superdesk.uniorder.dao.entity.operationCenter.UnifiedOperators">
    update unified_operators
    set name = #{name,jdbcType=VARCHAR},
      biz_platform_code = #{bizPlatformCode,jdbcType=VARCHAR},
      biz_platform_name = #{bizPlatformName,jdbcType=VARCHAR},
      biz_operator_code = #{bizOperatorCode,jdbcType=VARCHAR},
      biz_operator_id = #{bizOperatorId,jdbcType=VARCHAR},
      contact = #{contact,jdbcType=VARCHAR},
      mobile = #{mobile,jdbcType=VARCHAR},
      address = #{address,jdbcType=VARCHAR},
      remark = #{remark,jdbcType=VARCHAR},
      longitude = #{longitude,jdbcType=VARCHAR},
      latitude = #{latitude,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      create_user_id = #{createUserId,jdbcType=BIGINT},
      update_time = #{updateTime,jdbcType=TIMESTAMP},
      update_user_id = #{updateUserId,jdbcType=BIGINT},
      deleted = #{deleted,jdbcType=TINYINT}
    where id = #{id,jdbcType=BIGINT}
  </update>

  <select id="getOpCenterOperatorList"
          resultType="cn.superdesk.uniorder.dto.vo.operationCenter.operators.OperationCenterOperatorsVo"
          parameterType="cn.superdesk.uniorder.dto.param.operationCenter.operators.OperationCenterOperatorsParam">
    SELECT t.id,
    t.`name`,
    t.biz_platform_name bizPlatformName,
    t.biz_platform_code bizPlatformCode,
    t.biz_operator_id operatorsId,
    t.contact,
    t.remark,
    t.update_time updateTime

    FROM unified_operators t
    where 1=1
    <if test=" platformCode != null and platformCode !=''">
      and t.biz_platform_code=#{platformCode}
    </if>
    <if test=" operatorsName != null and operatorsName !=''">
      and t.NAME like CONCAT ('%',#{operatorsName},'%')
    </if>
    <if test=" operatorsIdList != null and operatorsIdList.size() >0 ">
      and t.id in
         <foreach collection="operatorsIdList" index="index" open="(" close=")" item="operatorId" separator=",">
            #{operatorId}
         </foreach>
    </if>
    order by t.update_time desc
  </select>
  <select id="selectOperationCenterOperators"
          resultType="cn.superdesk.uniorder.dto.vo.operationCenter.base.OperationCenterVo">
    SELECT   t. id code,CONCAT(t.`name`,'(',t.biz_platform_name,')') name
    FROM unified_operators t
  </select>

  <resultMap id="OperatorsMap" type="cn.superdesk.uniorder.dto.vo.operationCenter.operators.OperationCenterPaymentOperatorVo">
    <result column="biz_operator_id" jdbcType="VARCHAR" property="operatorsId" />
    <result column="name" jdbcType="VARCHAR" property="operatorsName" />
    <result column="biz_platform_name" jdbcType="VARCHAR" property="platFormName" />
  </resultMap>
</mapper>