<?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 2021 . All rights reserved. -->
<!--  Mybatis数据库持久层（底层映射文件）：测试点中间表 -->
<!--  version: 1.0  -->
<!--  author:  maven-cctp-plugin    -->
<!--  date:  2021-12-15 17:46:49  -->
<mapper namespace="net.northking.cctp.dw.db.dao.MidTestPointDao">
  <resultMap id="BaseResultMap" type="net.northking.cctp.dw.db.entity.MidTestPoint">
      <!--  -->
    <id column="id" jdbcType="BIGINT" property="id"/>
                        <!-- 租户id -->
    <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
        <!-- 系统id -->
    <result column="project_id" jdbcType="VARCHAR" property="projectId"/>
        <!-- 已完成数量 -->
    <result column="completed" jdbcType="INTEGER" property="completed"/>
        <!-- 创建日期 -->
    <result column="created_time" jdbcType="DATE" property="createdTime"/>
        <!-- 总数 -->
    <result column="total" jdbcType="INTEGER" property="total"/>
        <!-- 未完成数量 -->
    <result column="uncompleted" jdbcType="INTEGER" property="uncompleted"/>
    </resultMap>

  <sql id="Base_Column_List">
    id
    ,tenant_id
    ,project_id
    ,completed
    ,created_time
    ,total
    ,uncompleted
  </sql>

  <sql id="Table_Name">
    mid_test_point
  </sql>

  <select id="findByPrimaryKey" parameterType="Long" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List"/>
    from
    <include refid="Table_Name"/>
    where id = #{id,jdbcType=BIGINT}
  </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=BIGINT}
    </foreach>
  </select>

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

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

  <delete id="deleteByExample" parameterType="net.northking.cctp.dw.db.entity.MidTestPoint">
    delete from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
          AND id=#{id,jdbcType=BIGINT}
      </if>
      <if test="tenantId != null">
          AND tenant_id=#{tenantId,jdbcType=VARCHAR}
      </if>
      <if test="projectId != null">
          AND project_id=#{projectId,jdbcType=VARCHAR}
      </if>
      <if test="completed != null">
          AND completed=#{completed,jdbcType=INTEGER}
      </if>
      <if test="createdTime != null">
          AND created_time=#{createdTime,jdbcType=DATE}
      </if>
      <if test="total != null">
          AND total=#{total,jdbcType=INTEGER}
      </if>
      <if test="uncompleted != null">
          AND uncompleted=#{uncompleted,jdbcType=INTEGER}
      </if>
    </trim>
  </delete>

  <insert id="insert" parameterType="net.northking.cctp.dw.db.entity.MidTestPoint">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="tenantId != null">
        tenant_id,
      </if>
      <if test="projectId != null">
        project_id,
      </if>
      <if test="completed != null">
        completed,
      </if>
      <if test="createdTime != null">
        created_time,
      </if>
      <if test="total != null">
        total,
      </if>
      <if test="uncompleted != null">
        uncompleted,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
          #{id, jdbcType=BIGINT},
      </if>
      <if test="tenantId != null">
          #{tenantId, jdbcType=VARCHAR},
      </if>
      <if test="projectId != null">
          #{projectId, jdbcType=VARCHAR},
      </if>
      <if test="completed != null">
          #{completed, jdbcType=INTEGER},
      </if>
      <if test="createdTime != null">
          #{createdTime, jdbcType=DATE},
      </if>
      <if test="total != null">
          #{total, jdbcType=INTEGER},
      </if>
      <if test="uncompleted != null">
          #{uncompleted, jdbcType=INTEGER},
      </if>
    </trim>
  </insert>

  <insert id="insertByBatch" parameterType="java.util.List">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
    id,
    tenant_id,
    project_id,
    completed,
    created_time,
    total,
    uncompleted,
    </trim>
    values
    <foreach collection="list" item="item" index="index" separator=",">
      <trim prefix="(" suffix=")" suffixOverrides=",">
    #{item.id, jdbcType=BIGINT},
    #{item.tenantId, jdbcType=VARCHAR},
    #{item.projectId, jdbcType=VARCHAR},
    #{item.completed, jdbcType=INTEGER},
    #{item.createdTime, jdbcType=DATE},
    #{item.total, jdbcType=INTEGER},
    #{item.uncompleted, jdbcType=INTEGER},
      </trim>
    </foreach>
  </insert>

  <update id="updateByPrimaryKey" parameterType="net.northking.cctp.dw.db.entity.MidTestPoint">
    update
    <include refid="Table_Name"/>
    <set>
      <if test="projectId != null">
        project_id = #{projectId, jdbcType=VARCHAR},
      </if>
      <if test="completed != null">
        completed = #{completed, jdbcType=INTEGER},
      </if>
      <if test="createdTime != null">
        created_time = #{createdTime, jdbcType=DATE},
      </if>
      <if test="total != null">
        total = #{total, jdbcType=INTEGER},
      </if>
      <if test="uncompleted != null">
        uncompleted = #{uncompleted, jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
    AND tenant_id = #{tenantId,jdbcType=VARCHAR}
  </update>

  <select id="query" resultMap="BaseResultMap" parameterType="net.northking.cctp.dw.db.entity.MidTestPoint">
    select
    <include refid="Base_Column_List" />
    from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id = #{id,jdbcType=BIGINT}
      </if>
      <if test="tenantId != null">
        AND tenant_id = #{tenantId,jdbcType=VARCHAR}
      </if>
      <if test="projectId != null">
        AND project_id = #{projectId,jdbcType=VARCHAR}
      </if>
      <if test="completed != null">
        AND completed = #{completed,jdbcType=INTEGER}
      </if>
      <if test="createdTime != null">
        AND created_time = #{createdTime,jdbcType=DATE}
      </if>
      <if test="total != null">
        AND total = #{total,jdbcType=INTEGER}
      </if>
      <if test="uncompleted != null">
        AND uncompleted = #{uncompleted,jdbcType=INTEGER}
      </if>
    </trim>
  </select>

  <select id="queryCount" resultType="java.lang.Long" parameterType="net.northking.cctp.dw.db.entity.MidTestPoint">
    select count(*) from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id=#{id,jdbcType=BIGINT}
      </if>
      <if test="tenantId != null">
        AND tenant_id=#{tenantId,jdbcType=VARCHAR}
      </if>
      <if test="projectId != null">
        AND project_id=#{projectId,jdbcType=VARCHAR}
      </if>
      <if test="completed != null">
        AND completed=#{completed,jdbcType=INTEGER}
      </if>
      <if test="createdTime != null">
        AND created_time=#{createdTime,jdbcType=DATE}
      </if>
      <if test="total != null">
        AND total=#{total,jdbcType=INTEGER}
      </if>
      <if test="uncompleted != null">
        AND uncompleted=#{uncompleted,jdbcType=INTEGER}
      </if>
    </trim>
  </select>

</mapper>