<?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-29 10:24:37  -->
<mapper namespace="net.northking.cctp.device.db.dao.CdEngineInfoDao">
  <resultMap id="BaseResultMap" type="net.northking.cctp.device.db.entity.CdEngineInfo">
      <!-- 主键id -->
    <id column="id" jdbcType="VARCHAR" property="id"/>
                            <!-- 引擎名称 -->
    <result column="engine_name" jdbcType="VARCHAR" property="engineName"/>
        <!-- pc设备id -->
    <result column="device_id" jdbcType="VARCHAR" property="deviceId"/>
        <!-- ip地址 -->
    <result column="ip_addr" jdbcType="VARCHAR" property="ipAddr"/>
        <!-- ip端口 -->
    <result column="ip_port" jdbcType="VARCHAR" property="ipPort"/>
        <!-- 引擎版本 -->
    <result column="running_release" jdbcType="VARCHAR" property="runningRelease"/>
        <!-- 注册时间 -->
    <result column="registed_time" jdbcType="TIMESTAMP" property="registedTime"/>
        <!-- 启用/禁用 -->
    <result column="is_enabled" jdbcType="BIT" property="enabled"/>
        <!-- 引擎状态 -->
    <result column="engine_status" jdbcType="VARCHAR" property="engineStatus"/>
        <!-- 引擎描述 -->
    <result column="engine_desc" jdbcType="VARCHAR" property="engineDesc"/>

    <result column="last_heartbeat_time" jdbcType="TIMESTAMP" property="lastHeartbeatTime"/>
    </resultMap>

  <sql id="Base_Column_List">
    id
    ,engine_name
    ,device_id
    ,ip_addr
    ,ip_port
    ,running_release
    ,registed_time
    ,is_enabled
    ,engine_status
    ,engine_desc
    ,last_heartbeat_time
  </sql>

  <sql id="Table_Name">
    ${defaultSchema}.cd_engine_info
  </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.CdEngineInfo">
    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="engineName != null">
          AND engine_name=#{engineName,jdbcType=VARCHAR}
        </if>
              <if test="deviceId != null">
          AND device_id=#{deviceId,jdbcType=VARCHAR}
        </if>
              <if test="ipAddr != null">
          AND ip_addr=#{ipAddr,jdbcType=VARCHAR}
        </if>
              <if test="ipPort != null">
          AND ip_port=#{ipPort,jdbcType=VARCHAR}
        </if>
              <if test="runningRelease != null">
          AND running_release=#{runningRelease,jdbcType=VARCHAR}
        </if>
              <if test="registedTime != null">
          AND registed_time=#{registedTime,jdbcType=TIMESTAMP}
        </if>
              <if test="enabled != null">
          AND is_enabled=#{enabled,jdbcType=BIT}
        </if>
              <if test="engineStatus != null">
          AND engine_status=#{engineStatus,jdbcType=VARCHAR}
        </if>
              <if test="engineDesc != null">
          AND engine_desc=#{engineDesc,jdbcType=VARCHAR}
        </if>
              <if test="lastHeartbeatTime != null">
          AND last_heartbeat_time=#{lastHeartbeatTime,jdbcType=TIMESTAMP}
        </if>
          </trim>
  </delete>

  <insert id="insert" parameterType="net.northking.cctp.device.db.entity.CdEngineInfo">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="engineName != null">
        engine_name,
      </if>
      <if test="deviceId != null">
        device_id,
      </if>
      <if test="ipAddr != null">
        ip_addr,
      </if>
      <if test="ipPort != null">
        ip_port,
      </if>
      <if test="runningRelease != null">
        running_release,
      </if>
      <if test="registedTime != null">
        registed_time,
      </if>
      <if test="enabled != null">
        is_enabled,
      </if>
      <if test="engineStatus != null">
        engine_status,
      </if>
      <if test="engineDesc != null">
        engine_desc,
      </if>
      <if test="lastHeartbeatTime != null">
        last_heartbeat_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
          #{id, jdbcType=VARCHAR},
      </if>
      <if test="engineName != null">
          #{engineName, jdbcType=VARCHAR},
      </if>
      <if test="deviceId != null">
          #{deviceId, jdbcType=VARCHAR},
      </if>
      <if test="ipAddr != null">
          #{ipAddr, jdbcType=VARCHAR},
      </if>
      <if test="ipPort != null">
          #{ipPort, jdbcType=VARCHAR},
      </if>
      <if test="runningRelease != null">
          #{runningRelease, jdbcType=VARCHAR},
      </if>
      <if test="registedTime != null">
          #{registedTime, jdbcType=TIMESTAMP},
      </if>
      <if test="enabled != null">
          #{enabled, jdbcType=BIT},
      </if>
      <if test="engineStatus != null">
          #{engineStatus, jdbcType=VARCHAR},
      </if>
      <if test="engineDesc != null">
          #{engineDesc, jdbcType=VARCHAR},
      </if>
      <if test="lastHeartbeatTime != null">
          #{lastHeartbeatTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>

  <insert id="insertByBatch" parameterType="java.util.List">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
    id,
    engine_name,
    device_id,
    ip_addr,
    ip_port,
    running_release,
    registed_time,
    is_enabled,
    engine_status,
    engine_desc,
    last_heartbeat_time,
    </trim>
    values
    <foreach collection="list" item="item" index="index" separator=",">
      <trim prefix="(" suffix=")" suffixOverrides=",">
    #{item.id, jdbcType=VARCHAR},
    #{item.engineName, jdbcType=VARCHAR},
    #{item.deviceId, jdbcType=VARCHAR},
    #{item.ipAddr, jdbcType=VARCHAR},
    #{item.ipPort, jdbcType=VARCHAR},
    #{item.runningRelease, jdbcType=VARCHAR},
    #{item.registedTime, jdbcType=TIMESTAMP},
    #{item.enabled, jdbcType=BIT},
    #{item.engineStatus, jdbcType=VARCHAR},
    #{item.engineDesc, jdbcType=VARCHAR},
    #{item.lastHeartbeatTime,jdbcType=TIMESTAMP},
      </trim>
    </foreach>
  </insert>

  <update id="updateByPrimaryKey" parameterType="net.northking.cctp.device.db.entity.CdEngineInfo">
    update
    <include refid="Table_Name"/>
    <set>
      <if test="engineName != null">
        engine_name = #{engineName, jdbcType=VARCHAR},
      </if>
      <if test="deviceId != null">
        device_id = #{deviceId, jdbcType=VARCHAR},
      </if>
      <if test="ipAddr != null">
        ip_addr = #{ipAddr, jdbcType=VARCHAR},
      </if>
      <if test="ipPort != null">
        ip_port = #{ipPort, jdbcType=VARCHAR},
      </if>
      <if test="runningRelease != null">
        running_release = #{runningRelease, jdbcType=VARCHAR},
      </if>
      <if test="registedTime != null">
        registed_time = #{registedTime, jdbcType=TIMESTAMP},
      </if>
      <if test="enabled != null">
        is_enabled = #{enabled, jdbcType=BIT},
      </if>
      <if test="engineStatus != null">
        engine_status = #{engineStatus, jdbcType=VARCHAR},
      </if>
      <if test="engineDesc != null">
        engine_desc = #{engineDesc, jdbcType=VARCHAR},
      </if>
      <if test="lastHeartbeatTime != null">
        last_heartbeat_time = #{lastHeartbeatTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>

  <select id="query" resultMap="BaseResultMap" parameterType="net.northking.cctp.device.db.entity.CdEngineInfo">
    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="engineName != null">
        AND engine_name = #{engineName,jdbcType=VARCHAR}
      </if>
      <if test="deviceId != null">
        AND device_id = #{deviceId,jdbcType=VARCHAR}
      </if>
      <if test="ipAddr != null">
        AND ip_addr = #{ipAddr,jdbcType=VARCHAR}
      </if>
      <if test="ipPort != null">
        AND ip_port = #{ipPort,jdbcType=VARCHAR}
      </if>
      <if test="runningRelease != null">
        AND running_release = #{runningRelease,jdbcType=VARCHAR}
      </if>
      <if test="registedTime != null">
        AND registed_time = #{registedTime,jdbcType=TIMESTAMP}
      </if>
      <if test="enabled != null">
        AND is_enabled = #{enabled,jdbcType=BIT}
      </if>
      <if test="engineStatus != null">
        AND engine_status = #{engineStatus,jdbcType=VARCHAR}
      </if>
      <if test="engineDesc != null">
        AND engine_desc = #{engineDesc,jdbcType=VARCHAR}
      </if>
      <if test="lastHeartbeatTime != null">
        AND last_heartbeat_time = #{lastHeartbeatTime,jdbcType=TIMESTAMP}
      </if>
    </trim>
  </select>

  <select id="queryCount" resultType="java.lang.Long" parameterType="net.northking.cctp.device.db.entity.CdEngineInfo">
    select count(*) from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id=#{id,jdbcType=VARCHAR}
      </if>
      <if test="engineName != null">
        AND engine_name=#{engineName,jdbcType=VARCHAR}
      </if>
      <if test="deviceId != null">
        AND device_id=#{deviceId,jdbcType=VARCHAR}
      </if>
      <if test="ipAddr != null">
        AND ip_addr=#{ipAddr,jdbcType=VARCHAR}
      </if>
      <if test="ipPort != null">
        AND ip_port=#{ipPort,jdbcType=VARCHAR}
      </if>
      <if test="runningRelease != null">
        AND running_release=#{runningRelease,jdbcType=VARCHAR}
      </if>
      <if test="registedTime != null">
        AND registed_time=#{registedTime,jdbcType=TIMESTAMP}
      </if>
      <if test="enabled != null">
        AND is_enabled=#{enabled,jdbcType=BIT}
      </if>
      <if test="engineStatus != null">
        AND engine_status=#{engineStatus,jdbcType=VARCHAR}
      </if>
      <if test="engineDesc != null">
        AND engine_desc=#{engineDesc,jdbcType=VARCHAR}
      </if>
      <if test="lastHeartbeatTime != null">
        AND last_heartbeat_time = #{lastHeartbeatTime,jdbcType=TIMESTAMP}
      </if>
    </trim>
  </select>

</mapper>