<?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-21 14:10:19  -->
<mapper namespace="net.northking.cctp.device.db.dao.CdMobileDeviceDao">
  <resultMap id="BaseResultMap" type="net.northking.cctp.device.db.entity.CdMobileDevice">
      <!-- 主键id -->
    <id column="id" jdbcType="VARCHAR" property="id"/>
                            <!-- 型号id -->
    <result column="model_id" jdbcType="VARCHAR" property="modelId"/>
        <!-- 平台类型 -->
    <result column="platform" jdbcType="VARCHAR" property="platform"/>
        <!-- 平台版本 -->
    <result column="platform_version" jdbcType="VARCHAR" property="platformVersion"/>
        <!-- 上位机id -->
    <result column="ctrl_id" jdbcType="VARCHAR" property="ctrlId"/>
        <!-- wda地址 -->
    <result column="wda_url" jdbcType="VARCHAR" property="wdaUrl"/>
        <!-- 注册时间 -->
    <result column="registed_time" jdbcType="TIMESTAMP" property="registedTime"/>
        <!-- 更新人 -->
    <result column="updated_by" jdbcType="VARCHAR" property="updatedBy"/>
        <!-- 更新时间 -->
    <result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime"/>
        <!-- 租户id -->
    <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
    </resultMap>

  <sql id="Base_Column_List">
    id
    ,model_id
    ,platform
    ,platform_version
    ,ctrl_id
    ,wda_url
    ,registed_time
    ,updated_by
    ,updated_time
    ,tenant_id
  </sql>

  <sql id="Table_Name">
    ${defaultSchema}.cd_mobile_device
  </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.CdMobileDevice">
    delete from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
          AND id=#{id,jdbcType=VARCHAR}
      </if>
      <if test="modelId != null">
          AND model_id=#{modelId,jdbcType=VARCHAR}
      </if>
      <if test="platform != null">
          AND platform=#{platform,jdbcType=VARCHAR}
      </if>
      <if test="platformVersion != null">
          AND platform_version=#{platformVersion,jdbcType=VARCHAR}
      </if>
      <if test="ctrlId != null">
          AND ctrl_id=#{ctrlId,jdbcType=VARCHAR}
      </if>
      <if test="wdaUrl != null">
          AND wda_url=#{wdaUrl,jdbcType=VARCHAR}
      </if>
      <if test="registedTime != null">
          AND registed_time=#{registedTime,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>
      <if test="tenantId != null">
          AND tenant_id=#{tenantId,jdbcType=VARCHAR}
      </if>
    </trim>
  </delete>

  <insert id="insert" parameterType="net.northking.cctp.device.db.entity.CdMobileDevice">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="modelId != null">
        model_id,
      </if>
      <if test="platform != null">
        platform,
      </if>
      <if test="platformVersion != null">
        platform_version,
      </if>
      <if test="ctrlId != null">
        ctrl_id,
      </if>
      <if test="wdaUrl != null">
        wda_url,
      </if>
      <if test="registedTime != null">
        registed_time,
      </if>
      <if test="updatedBy != null">
        updated_by,
      </if>
      <if test="updatedTime != null">
        updated_time,
      </if>
      <if test="tenantId != null">
        tenant_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
          #{id, jdbcType=VARCHAR},
      </if>
      <if test="modelId != null">
          #{modelId, jdbcType=VARCHAR},
      </if>
      <if test="platform != null">
          #{platform, jdbcType=VARCHAR},
      </if>
      <if test="platformVersion != null">
          #{platformVersion, jdbcType=VARCHAR},
      </if>
      <if test="ctrlId != null">
          #{ctrlId, jdbcType=VARCHAR},
      </if>
      <if test="wdaUrl != null">
          #{wdaUrl, jdbcType=VARCHAR},
      </if>
      <if test="registedTime != null">
          #{registedTime, jdbcType=TIMESTAMP},
      </if>
      <if test="updatedBy != null">
          #{updatedBy, jdbcType=VARCHAR},
      </if>
      <if test="updatedTime != null">
          #{updatedTime, jdbcType=TIMESTAMP},
      </if>
      <if test="tenantId != null">
          #{tenantId, jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>

  <insert id="insertByBatch" parameterType="java.util.List">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
    id,
    model_id,
    platform,
    platform_version,
    ctrl_id,
    wda_url,
    registed_time,
    updated_by,
    updated_time,
    tenant_id,
    </trim>
    values
    <foreach collection="list" item="item" index="index" separator=",">
      <trim prefix="(" suffix=")" suffixOverrides=",">
    #{item.id, jdbcType=VARCHAR},
    #{item.modelId, jdbcType=VARCHAR},
    #{item.platform, jdbcType=VARCHAR},
    #{item.platformVersion, jdbcType=VARCHAR},
    #{item.ctrlId, jdbcType=VARCHAR},
    #{item.wdaUrl, jdbcType=VARCHAR},
    #{item.registedTime, jdbcType=TIMESTAMP},
    #{item.updatedBy, jdbcType=VARCHAR},
    #{item.updatedTime, jdbcType=TIMESTAMP},
    #{item.tenantId, jdbcType=VARCHAR},
      </trim>
    </foreach>
  </insert>

  <update id="updateByPrimaryKey" parameterType="net.northking.cctp.device.db.entity.CdMobileDevice">
    update
    <include refid="Table_Name"/>
    <set>
      <if test="modelId != null">
        model_id = #{modelId, jdbcType=VARCHAR},
      </if>
      <if test="platform != null">
        platform = #{platform, jdbcType=VARCHAR},
      </if>
      <if test="platformVersion != null">
        platform_version = #{platformVersion, jdbcType=VARCHAR},
      </if>
      <if test="ctrlId != null">
        ctrl_id = #{ctrlId, jdbcType=VARCHAR},
      </if>
      <if test="wdaUrl != null">
        wda_url = #{wdaUrl, jdbcType=VARCHAR},
      </if>
      <if test="registedTime != null">
        registed_time = #{registedTime, 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.CdMobileDevice">
    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="modelId != null">
        AND model_id = #{modelId,jdbcType=VARCHAR}
      </if>
      <if test="platform != null">
        AND platform = #{platform,jdbcType=VARCHAR}
      </if>
      <if test="platformVersion != null">
        AND platform_version = #{platformVersion,jdbcType=VARCHAR}
      </if>
      <if test="ctrlId != null">
        AND ctrl_id = #{ctrlId,jdbcType=VARCHAR}
      </if>
      <if test="wdaUrl != null">
        AND wda_url = #{wdaUrl,jdbcType=VARCHAR}
      </if>
      <if test="registedTime != null">
        AND registed_time = #{registedTime,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>
      <if test="tenantId != null">
        AND tenant_id = #{tenantId,jdbcType=VARCHAR}
      </if>
    </trim>
  </select>

  <select id="queryCount" resultType="java.lang.Long" parameterType="net.northking.cctp.device.db.entity.CdMobileDevice">
    select count(*) from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id=#{id,jdbcType=VARCHAR}
      </if>
      <if test="modelId != null">
        AND model_id=#{modelId,jdbcType=VARCHAR}
      </if>
      <if test="platform != null">
        AND platform=#{platform,jdbcType=VARCHAR}
      </if>
      <if test="platformVersion != null">
        AND platform_version=#{platformVersion,jdbcType=VARCHAR}
      </if>
      <if test="ctrlId != null">
        AND ctrl_id=#{ctrlId,jdbcType=VARCHAR}
      </if>
      <if test="wdaUrl != null">
        AND wda_url = #{wdaUrl,jdbcType=VARCHAR}
      </if>
      <if test="registedTime != null">
        AND registed_time=#{registedTime,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>
      <if test="tenantId != null">
        AND tenant_id=#{tenantId,jdbcType=VARCHAR}
      </if>
    </trim>
  </select>

</mapper>