<?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-22 16:34:55  -->
<mapper namespace="net.northking.cctp.device.db.dao.CdDeviceUsageLogDao">
  <resultMap id="BaseResultMap" type="net.northking.cctp.device.db.entity.CdDeviceUsageLog">
      <!-- 主键id -->
    <id column="id" jdbcType="VARCHAR" property="id"/>
                                  <!-- 设备id -->
    <result column="device_id" jdbcType="VARCHAR" property="deviceId"/>
        <!-- 设备类型(1-移动 2-PC) -->
    <result column="device_type" jdbcType="VARCHAR" property="deviceType"/>
        <!-- 开始时间 -->
    <result column="start_time" jdbcType="TIMESTAMP" property="startTime"/>
        <!-- 结束时间 -->
    <result column="end_time" jdbcType="TIMESTAMP" property="endTime"/>
        <!-- 使用日志 -->
    <result column="usage_log" jdbcType="VARCHAR" property="usageLog"/>
        <!-- 使用人 -->
    <result column="user_by" jdbcType="VARCHAR" property="userBy"/>
        <!-- 使用人ip -->
    <result column="user_ip" jdbcType="VARCHAR" property="userIp"/>
        <!-- 创建人 -->
    <result column="created_by" jdbcType="VARCHAR" property="createdBy"/>
        <!-- 创建时间 -->
    <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
    ,device_id
    ,device_type
    ,start_time
    ,end_time
    ,usage_log
    ,user_by
    ,user_ip
    ,created_by
    ,created_time
    ,updated_by
    ,updated_time
  </sql>

  <sql id="Table_Name">
    ${defaultSchema}.cd_device_usage_log
  </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.CdDeviceUsageLog">
    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="deviceId != null">
          AND device_id=#{deviceId,jdbcType=VARCHAR}
        </if>
              <if test="deviceType != null">
          AND device_type=#{deviceType,jdbcType=VARCHAR}
        </if>
              <if test="startTime != null">
          AND start_time=#{startTime,jdbcType=TIMESTAMP}
        </if>
              <if test="endTime != null">
          AND end_time=#{endTime,jdbcType=TIMESTAMP}
        </if>
              <if test="usageLog != null">
          AND usage_log=#{usageLog,jdbcType=VARCHAR}
        </if>
              <if test="userBy != null">
          AND user_by=#{userBy,jdbcType=VARCHAR}
        </if>
              <if test="userIp != null">
          AND user_ip=#{userIp,jdbcType=VARCHAR}
        </if>
              <if test="createdBy != null">
          AND created_by=#{createdBy,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.CdDeviceUsageLog">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="deviceId != null">
        device_id,
      </if>
      <if test="deviceType != null">
        device_type,
      </if>
      <if test="startTime != null">
        start_time,
      </if>
      <if test="endTime != null">
        end_time,
      </if>
      <if test="usageLog != null">
        usage_log,
      </if>
      <if test="userBy != null">
        user_by,
      </if>
      <if test="userIp != null">
        user_ip,
      </if>
      <if test="createdBy != null">
        created_by,
      </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="deviceId != null">
          #{deviceId, jdbcType=VARCHAR},
      </if>
      <if test="deviceType != null">
          #{deviceType, jdbcType=VARCHAR},
      </if>
      <if test="startTime != null">
          #{startTime, jdbcType=TIMESTAMP},
      </if>
      <if test="endTime != null">
          #{endTime, jdbcType=TIMESTAMP},
      </if>
      <if test="usageLog != null">
          #{usageLog, jdbcType=VARCHAR},
      </if>
      <if test="userBy != null">
          #{userBy, jdbcType=VARCHAR},
      </if>
      <if test="userIp != null">
          #{userIp, jdbcType=VARCHAR},
      </if>
      <if test="createdBy != null">
          #{createdBy, 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,
    device_id,
    device_type,
    start_time,
    end_time,
    usage_log,
    user_by,
    user_ip,
    created_by,
    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.deviceId, jdbcType=VARCHAR},
    #{item.deviceType, jdbcType=VARCHAR},
    #{item.startTime, jdbcType=TIMESTAMP},
    #{item.endTime, jdbcType=TIMESTAMP},
    #{item.usageLog, jdbcType=VARCHAR},
    #{item.userBy, jdbcType=VARCHAR},
    #{item.userIp, jdbcType=VARCHAR},
    #{item.createdBy, 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.CdDeviceUsageLog">
    update
    <include refid="Table_Name"/>
    <set>
      <if test="deviceId != null">
        device_id = #{deviceId, jdbcType=VARCHAR},
      </if>
      <if test="deviceType != null">
        device_type = #{deviceType, jdbcType=VARCHAR},
      </if>
      <if test="startTime != null">
        start_time = #{startTime, jdbcType=TIMESTAMP},
      </if>
      <if test="endTime != null">
        end_time = #{endTime, jdbcType=TIMESTAMP},
      </if>
      <if test="usageLog != null">
        usage_log = #{usageLog, jdbcType=VARCHAR},
      </if>
      <if test="userBy != null">
        user_by = #{userBy, jdbcType=VARCHAR},
      </if>
      <if test="userIp != null">
        user_ip = #{userIp, jdbcType=VARCHAR},
      </if>
      <if test="createdBy != null">
        created_by = #{createdBy, 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.CdDeviceUsageLog">
    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="deviceId != null">
        AND device_id = #{deviceId,jdbcType=VARCHAR}
      </if>
      <if test="deviceType != null">
        AND device_type = #{deviceType,jdbcType=VARCHAR}
      </if>
      <if test="startTime != null">
        AND start_time = #{startTime,jdbcType=TIMESTAMP}
      </if>
      <if test="endTime != null">
        AND end_time = #{endTime,jdbcType=TIMESTAMP}
      </if>
      <if test="usageLog != null">
        AND usage_log = #{usageLog,jdbcType=VARCHAR}
      </if>
      <if test="userBy != null">
        AND user_by = #{userBy,jdbcType=VARCHAR}
      </if>
      <if test="userIp != null">
        AND user_ip = #{userIp,jdbcType=VARCHAR}
      </if>
      <if test="createdBy != null">
        AND created_by = #{createdBy,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.CdDeviceUsageLog">
    select count(*) from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id=#{id,jdbcType=VARCHAR}
      </if>
      <if test="deviceId != null">
        AND device_id=#{deviceId,jdbcType=VARCHAR}
      </if>
      <if test="deviceType != null">
        AND device_type=#{deviceType,jdbcType=VARCHAR}
      </if>
      <if test="startTime != null">
        AND start_time=#{startTime,jdbcType=TIMESTAMP}
      </if>
      <if test="endTime != null">
        AND end_time=#{endTime,jdbcType=TIMESTAMP}
      </if>
      <if test="usageLog != null">
        AND usage_log=#{usageLog,jdbcType=VARCHAR}
      </if>
      <if test="userBy != null">
        AND user_by=#{userBy,jdbcType=VARCHAR}
      </if>
      <if test="userIp != null">
        AND user_ip=#{userIp,jdbcType=VARCHAR}
      </if>
      <if test="createdBy != null">
        AND created_by=#{createdBy,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>