<?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">
<!--  Copyright (c) 京北方信息技术股份有限公司 Corporation 2022 . All rights reserved. -->
<!--  文件内容由代码生成器产生，请不要手动修改！ -->
<!--  version: 1.0  -->
<!--  author:  maven-cctp-plugin    -->
<!--  date:  2022-09-13 17:29:53  -->
<mapper namespace="net.northking.cctp.device.db.dao.CdDeviceCtrlDao">
  <resultMap id="BaseResultMap" type="net.northking.cctp.device.db.entity.CdDeviceCtrl">
      <!-- 主键id -->
    <id column="id" jdbcType="VARCHAR" property="id"/>
                              <!-- 上位机名称 -->
    <result column="ctrl_name" jdbcType="VARCHAR" property="ctrlName"/>
        <!-- 上位机ip -->
    <result column="ctrl_ip" jdbcType="VARCHAR" property="ctrlIp"/>
        <!-- 上位机位置 -->
    <result column="ctrl_addr" jdbcType="VARCHAR" property="ctrlAddr"/>
    <!-- 上位机端口 -->
    <result column="ctrl_port" jdbcType="INTEGER" property="ctrlPort"/>
    <!-- appium端口 -->
    <result column="appium_port" jdbcType="INTEGER" property="appiumPort"/>
        <!-- 上位机状态 -->
    <result column="ctrl_status" jdbcType="VARCHAR" property="ctrlStatus"/>
        <!-- 接入设备上限 -->
    <result column="ctrl_up_limit" jdbcType="INTEGER" property="ctrlUpLimit"/>
        <!-- 备注 -->
    <result column="remark" jdbcType="VARCHAR" property="remark"/>
        <!-- 注册时间 -->
    <result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
        <!-- 更新人 -->
    <result column="updated_by" jdbcType="VARCHAR" property="updatedBy"/>
        <!-- 更新时间 -->
    <result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime"/>
    </resultMap>

  <sql id="Base_Column_List">
    id
    ,ctrl_name
    ,ctrl_ip
    ,ctrl_addr
    ,ctrl_port
    ,appium_port
    ,ctrl_status
    ,ctrl_up_limit
    ,remark
    ,created_time
    ,updated_by
    ,updated_time
  </sql>

  <sql id="Table_Name">
    ${defaultSchema}.cd_device_ctrl
  </sql>

  <select id="findByPrimaryKey" parameterType="String" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List"/>
    from
    <include refid="Table_Name"/>
    where id = #{id,jdbcType=VARCHAR}
  </select>

  <select id="findByPrimaryKeys" parameterType="java.util.List">
    select
    <include refid="Base_Column_List"/>
    from
    <include refid="Table_Name"/>
    where id in
    <foreach collection="list" item="idItem" open="(" separator="," close=")">
      #{idItem, jdbcType=VARCHAR}
    </foreach>
  </select>

  <delete id="deleteByPrimaryKey" parameterType="String">
    delete from
    <include refid="Table_Name"/>
    where id = #{id,jdbcType=VARCHAR}
  </delete>

  <delete id="deleteByPrimaryKeys" parameterType="String">
    delete from
    <include refid="Table_Name"/>
    where id in
    <foreach collection="list" item="idItem" open="(" separator="," close=")">
      #{idItem, jdbcType=VARCHAR}
    </foreach>
  </delete>

  <delete id="deleteByExample" parameterType="net.northking.cctp.device.db.entity.CdDeviceCtrl">
    delete from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <choose>
        <when test="id != null">
          id = #{id,jdbcType=VARCHAR}
        </when>
      </choose>
              <if test="id != null">
          AND id=#{id,jdbcType=VARCHAR}
        </if>
              <if test="ctrlName != null">
          AND ctrl_name=#{ctrlName,jdbcType=VARCHAR}
        </if>
              <if test="ctrlIp != null">
          AND ctrl_ip=#{ctrlIp,jdbcType=VARCHAR}
        </if>
              <if test="ctrlAddr != null">
          AND ctrl_addr=#{ctrlAddr,jdbcType=VARCHAR}
        </if>
              <if test="ctrlPort != null">
          AND ctrl_port=#{ctrlPort,jdbcType=INTEGER}
        </if>
              <if test="appiumPort != null">
          AND appium_port=#{appiumPort,jdbcType=INTEGER}
        </if>
              <if test="ctrlStatus != null">
          AND ctrl_status=#{ctrlStatus,jdbcType=VARCHAR}
        </if>
              <if test="ctrlUpLimit != null">
          AND ctrl_up_limit=#{ctrlUpLimit,jdbcType=INTEGER}
        </if>
              <if test="remark != null">
          AND remark=#{remark,jdbcType=VARCHAR}
        </if>
              <if test="createdTime != null">
          AND created_time=#{createdTime,jdbcType=TIMESTAMP}
        </if>
              <if test="updatedBy != null">
          AND updated_by=#{updatedBy,jdbcType=VARCHAR}
        </if>
              <if test="updatedTime != null">
          AND updated_time=#{updatedTime,jdbcType=TIMESTAMP}
        </if>
          </trim>
  </delete>

  <insert id="insert" parameterType="net.northking.cctp.device.db.entity.CdDeviceCtrl">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="ctrlName != null">
        ctrl_name,
      </if>
      <if test="ctrlIp != null">
        ctrl_ip,
      </if>
      <if test="ctrlAddr != null">
        ctrl_addr,
      </if>
      <if test="ctrlPort != null">
        ctrl_port,
      </if>
      <if test="appiumPort != null">
        appium_port,
      </if>
      <if test="ctrlStatus != null">
        ctrl_status,
      </if>
      <if test="ctrlUpLimit != null">
        ctrl_up_limit,
      </if>
      <if test="remark != null">
        remark,
      </if>
      <if test="createdTime != null">
        created_time,
      </if>
      <if test="updatedBy != null">
        updated_by,
      </if>
      <if test="updatedTime != null">
        updated_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
          #{id, jdbcType=VARCHAR},
      </if>
      <if test="ctrlName != null">
          #{ctrlName, jdbcType=VARCHAR},
      </if>
      <if test="ctrlIp != null">
          #{ctrlIp, jdbcType=VARCHAR},
      </if>
      <if test="ctrlAddr != null">
          #{ctrlAddr, jdbcType=VARCHAR},
      </if>
      <if test="ctrlPort != null">
          #{ctrlPort, jdbcType=INTEGER},
      </if>
      <if test="appiumPort != null">
          #{appiumPort, jdbcType=INTEGER},
      </if>
      <if test="ctrlStatus != null">
          #{ctrlStatus, jdbcType=VARCHAR},
      </if>
      <if test="ctrlUpLimit != null">
          #{ctrlUpLimit, jdbcType=INTEGER},
      </if>
      <if test="remark != null">
          #{remark, jdbcType=VARCHAR},
      </if>
      <if test="createdTime != null">
          #{createdTime, jdbcType=TIMESTAMP},
      </if>
      <if test="updatedBy != null">
          #{updatedBy, jdbcType=VARCHAR},
      </if>
      <if test="updatedTime != null">
          #{updatedTime, jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>

  <insert id="insertByBatch" parameterType="java.util.List">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
    id,
    ctrl_name,
    ctrl_ip,
    ctrl_addr,
    ctrl_port,
    appium_port,
    ctrl_status,
    ctrl_up_limit,
    remark,
    created_time,
    updated_by,
    updated_time,
    </trim>
    values
    <foreach collection="list" item="item" index="index" separator=",">
      <trim prefix="(" suffix=")" suffixOverrides=",">
    #{item.id, jdbcType=VARCHAR},
    #{item.ctrlName, jdbcType=VARCHAR},
    #{item.ctrlIp, jdbcType=VARCHAR},
    #{item.ctrlAddr, jdbcType=VARCHAR},
    #{item.ctrlPort, jdbcType=INTEGER},
    #{item.appiumPort, jdbcType=INTEGER},
    #{item.ctrlStatus, jdbcType=VARCHAR},
    #{item.ctrlUpLimit, jdbcType=INTEGER},
    #{item.remark, jdbcType=VARCHAR},
    #{item.createdTime, jdbcType=TIMESTAMP},
    #{item.updatedBy, jdbcType=VARCHAR},
    #{item.updatedTime, jdbcType=TIMESTAMP},
      </trim>
    </foreach>
  </insert>

  <update id="updateByPrimaryKey" parameterType="net.northking.cctp.device.db.entity.CdDeviceCtrl">
    update
    <include refid="Table_Name"/>
    <set>
      <if test="ctrlName != null">
        ctrl_name = #{ctrlName, jdbcType=VARCHAR},
      </if>
      <if test="ctrlIp != null">
        ctrl_ip = #{ctrlIp, jdbcType=VARCHAR},
      </if>
      <if test="ctrlAddr != null">
        ctrl_addr = #{ctrlAddr, jdbcType=VARCHAR},
      </if>
      <if test="ctrlPort != null">
        ctrl_port = #{ctrlPort, jdbcType=INTEGER},
      </if>
      <if test="appiumPort != null">
        appium_port = #{appiumPort, jdbcType=INTEGER},
      </if>
      <if test="ctrlStatus != null">
        ctrl_status = #{ctrlStatus, jdbcType=VARCHAR},
      </if>
      <if test="ctrlUpLimit != null">
        ctrl_up_limit = #{ctrlUpLimit, jdbcType=INTEGER},
      </if>
      <if test="remark != null">
        remark = #{remark, jdbcType=VARCHAR},
      </if>
      <if test="createdTime != null">
        created_time = #{createdTime, jdbcType=TIMESTAMP},
      </if>
      <if test="updatedBy != null">
        updated_by = #{updatedBy, jdbcType=VARCHAR},
      </if>
      <if test="updatedTime != null">
        updated_time = #{updatedTime, jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>

  <select id="query" resultMap="BaseResultMap" parameterType="net.northking.cctp.device.db.entity.CdDeviceCtrl">
    select
    <include refid="Base_Column_List" />
    from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id = #{id,jdbcType=VARCHAR}
      </if>
      <if test="ctrlName != null">
        AND ctrl_name = #{ctrlName,jdbcType=VARCHAR}
      </if>
      <if test="ctrlIp != null">
        AND ctrl_ip = #{ctrlIp,jdbcType=VARCHAR}
      </if>
      <if test="ctrlAddr != null">
        AND ctrl_addr = #{ctrlAddr,jdbcType=VARCHAR}
      </if>
      <if test="ctrlPort != null">
        AND ctrl_port = #{ctrlPort,jdbcType=INTEGER}
      </if>
      <if test="appiumPort != null">
        AND appium_port = #{appiumPort,jdbcType=INTEGER}
      </if>
      <if test="ctrlStatus != null">
        AND ctrl_status = #{ctrlStatus,jdbcType=VARCHAR}
      </if>
      <if test="ctrlUpLimit != null">
        AND ctrl_up_limit = #{ctrlUpLimit,jdbcType=INTEGER}
      </if>
      <if test="remark != null">
        AND remark = #{remark,jdbcType=VARCHAR}
      </if>
      <if test="createdTime != null">
        AND created_time = #{createdTime,jdbcType=TIMESTAMP}
      </if>
      <if test="updatedBy != null">
        AND updated_by = #{updatedBy,jdbcType=VARCHAR}
      </if>
      <if test="updatedTime != null">
        AND updated_time = #{updatedTime,jdbcType=TIMESTAMP}
      </if>
    </trim>
  </select>

  <select id="queryCount" resultType="java.lang.Long" parameterType="net.northking.cctp.device.db.entity.CdDeviceCtrl">
    select count(*) from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id=#{id,jdbcType=VARCHAR}
      </if>
      <if test="ctrlName != null">
        AND ctrl_name=#{ctrlName,jdbcType=VARCHAR}
      </if>
      <if test="ctrlIp != null">
        AND ctrl_ip=#{ctrlIp,jdbcType=VARCHAR}
      </if>
      <if test="ctrlAddr != null">
        AND ctrl_addr=#{ctrlAddr,jdbcType=VARCHAR}
      </if>
      <if test="ctrlPort != null">
        AND ctrl_port = #{ctrlPort,jdbcType=INTEGER}
      </if>
      <if test="appiumPort != null">
        AND appium_port = #{appiumPort,jdbcType=INTEGER}
      </if>
      <if test="ctrlStatus != null">
        AND ctrl_status=#{ctrlStatus,jdbcType=VARCHAR}
      </if>
      <if test="ctrlUpLimit != null">
        AND ctrl_up_limit=#{ctrlUpLimit,jdbcType=INTEGER}
      </if>
      <if test="remark != null">
        AND remark=#{remark,jdbcType=VARCHAR}
      </if>
      <if test="createdTime != null">
        AND created_time=#{createdTime,jdbcType=TIMESTAMP}
      </if>
      <if test="updatedBy != null">
        AND updated_by=#{updatedBy,jdbcType=VARCHAR}
      </if>
      <if test="updatedTime != null">
        AND updated_time=#{updatedTime,jdbcType=TIMESTAMP}
      </if>
    </trim>
  </select>

</mapper>