<?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. -->
<!--  Mybatis数据库持久层（底层映射文件）：用户有效执行用例数中间表 -->
<!--  version: 1.0  -->
<!--  author:  maven-cctp-plugin    -->
<!--  date:  2022-01-21 10:29:37  -->
<mapper namespace="net.northking.cctp.dw.db.dao.MidValidExecJobDao">
  <resultMap id="BaseResultMap" type="net.northking.cctp.dw.db.entity.MidValidExecJob">
      <!--  -->
    <id column="id" jdbcType="BIGINT" property="id"/>
                    <!-- 用例执行人 -->
    <result column="created_by" jdbcType="VARCHAR" property="createdBy"/>
        <!-- 有效执行数 -->
    <result column="valid_exec" jdbcType="INTEGER" property="validExec"/>
        <!-- 系统id -->
    <result column="project_id" jdbcType="VARCHAR" property="projectId"/>
        <!--  -->
    <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
    </resultMap>

  <sql id="Base_Column_List">
    id
    ,created_by
    ,valid_exec
    ,project_id
    ,tenant_id
  </sql>

  <sql id="Table_Name">
    mid_valid_exec_job
  </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.MidValidExecJob">
    delete from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
          AND id=#{id,jdbcType=BIGINT}
      </if>
      <if test="createdBy != null">
          AND created_by=#{createdBy,jdbcType=VARCHAR}
      </if>
      <if test="validExec != null">
          AND valid_exec=#{validExec,jdbcType=INTEGER}
      </if>
      <if test="projectId != null">
          AND project_id=#{projectId,jdbcType=VARCHAR}
      </if>
      <if test="tenantId != null">
          AND tenant_id=#{tenantId,jdbcType=VARCHAR}
      </if>
    </trim>
  </delete>

  <insert id="insert" parameterType="net.northking.cctp.dw.db.entity.MidValidExecJob">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="createdBy != null">
        created_by,
      </if>
      <if test="validExec != null">
        valid_exec,
      </if>
      <if test="projectId != null">
        project_id,
      </if>
      <if test="tenantId != null">
        tenant_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
          #{id, jdbcType=BIGINT},
      </if>
      <if test="createdBy != null">
          #{createdBy, jdbcType=VARCHAR},
      </if>
      <if test="validExec != null">
          #{validExec, jdbcType=INTEGER},
      </if>
      <if test="projectId != null">
          #{projectId, jdbcType=VARCHAR},
      </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,
    created_by,
    valid_exec,
    project_id,
    tenant_id,
    </trim>
    values
    <foreach collection="list" item="item" index="index" separator=",">
      <trim prefix="(" suffix=")" suffixOverrides=",">
    #{item.id, jdbcType=BIGINT},
    #{item.createdBy, jdbcType=VARCHAR},
    #{item.validExec, jdbcType=INTEGER},
    #{item.projectId, jdbcType=VARCHAR},
    #{item.tenantId, jdbcType=VARCHAR},
      </trim>
    </foreach>
  </insert>

  <update id="updateByPrimaryKey" parameterType="net.northking.cctp.dw.db.entity.MidValidExecJob">
    update
    <include refid="Table_Name"/>
    <set>
      <if test="createdBy != null">
        created_by = #{createdBy, jdbcType=VARCHAR},
      </if>
      <if test="validExec != null">
        valid_exec = #{validExec, jdbcType=INTEGER},
      </if>
      <if test="projectId != null">
        project_id = #{projectId, jdbcType=VARCHAR},
      </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.MidValidExecJob">
    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="createdBy != null">
        AND created_by = #{createdBy,jdbcType=VARCHAR}
      </if>
      <if test="validExec != null">
        AND valid_exec = #{validExec,jdbcType=INTEGER}
      </if>
      <if test="projectId != null">
        AND project_id = #{projectId,jdbcType=VARCHAR}
      </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.dw.db.entity.MidValidExecJob">
    select count(*) from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id=#{id,jdbcType=BIGINT}
      </if>
      <if test="createdBy != null">
        AND created_by=#{createdBy,jdbcType=VARCHAR}
      </if>
      <if test="validExec != null">
        AND valid_exec=#{validExec,jdbcType=INTEGER}
      </if>
      <if test="projectId != null">
        AND project_id=#{projectId,jdbcType=VARCHAR}
      </if>
      <if test="tenantId != null">
        AND tenant_id=#{tenantId,jdbcType=VARCHAR}
      </if>
    </trim>
  </select>

</mapper>