<?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-11-25 11:15:19  -->
<mapper namespace="net.northking.cctp.dw.db.dao.DwAtuCaseDesignDao">
  <resultMap id="BaseResultMap" type="net.northking.cctp.dw.db.entity.DwAtuCaseDesign">
      <!--  -->
    <id column="id" jdbcType="VARCHAR" property="id"/>
                            <!--  -->
    <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
        <!--  -->
    <result column="project_id" jdbcType="VARCHAR" property="projectId"/>
        <!--  -->
    <result column="created_time" jdbcType="DATE" property="createdTime"/>
        <!--  -->
    <result column="created_by" jdbcType="VARCHAR" property="createdBy"/>
        <!--  -->
    <result column="case_name" jdbcType="VARCHAR" property="caseName"/>
        <!--  -->
    <result column="case_no" jdbcType="VARCHAR" property="caseNo"/>
        <!--  -->
    <result column="case_type" jdbcType="INTEGER" property="caseType"/>
        <!--  -->
    <result column="is_delete" jdbcType="INTEGER" property="isDelete"/>
    </resultMap>

  <sql id="Base_Column_List">
    id
    ,tenant_id
    ,project_id
    ,created_time
    ,created_by
    ,case_name
    ,case_no
    ,case_type
    ,is_delete
  </sql>

  <sql id="Table_Name">
    ${defaultSchema}.dw_atu_case_design
  </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.dw.db.entity.DwAtuCaseDesign">
    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="tenantId != null">
          AND tenant_id=#{tenantId,jdbcType=VARCHAR}
        </if>
              <if test="projectId != null">
          AND project_id=#{projectId,jdbcType=VARCHAR}
        </if>
              <if test="createdTime != null">
          AND created_time=#{createdTime,jdbcType=DATE}
        </if>
              <if test="createdBy != null">
          AND created_by=#{createdBy,jdbcType=VARCHAR}
        </if>
              <if test="caseName != null">
          AND case_name=#{caseName,jdbcType=VARCHAR}
        </if>
              <if test="caseNo != null">
          AND case_no=#{caseNo,jdbcType=VARCHAR}
        </if>
              <if test="caseType != null">
          AND case_type=#{caseType,jdbcType=INTEGER}
        </if>
              <if test="isDelete != null">
          AND is_delete=#{isDelete,jdbcType=INTEGER}
        </if>
          </trim>
  </delete>

  <insert id="insert" parameterType="net.northking.cctp.dw.db.entity.DwAtuCaseDesign">
    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="createdTime != null">
        created_time,
      </if>
      <if test="createdBy != null">
        created_by,
      </if>
      <if test="caseName != null">
        case_name,
      </if>
      <if test="caseNo != null">
        case_no,
      </if>
      <if test="caseType != null">
        case_type,
      </if>
      <if test="isDelete != null">
        is_delete,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
          #{id, jdbcType=VARCHAR},
      </if>
      <if test="tenantId != null">
          #{tenantId, jdbcType=VARCHAR},
      </if>
      <if test="projectId != null">
          #{projectId, jdbcType=VARCHAR},
      </if>
      <if test="createdTime != null">
          #{createdTime, jdbcType=DATE},
      </if>
      <if test="createdBy != null">
          #{createdBy, jdbcType=VARCHAR},
      </if>
      <if test="caseName != null">
          #{caseName, jdbcType=VARCHAR},
      </if>
      <if test="caseNo != null">
          #{caseNo, jdbcType=VARCHAR},
      </if>
      <if test="caseType != null">
          #{caseType, jdbcType=INTEGER},
      </if>
      <if test="isDelete != null">
          #{isDelete, 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,
    created_time,
    created_by,
    case_name,
    case_no,
    case_type,
    is_delete,
    </trim>
    values
    <foreach collection="list" item="item" index="index" separator=",">
      <trim prefix="(" suffix=")" suffixOverrides=",">
    #{item.id, jdbcType=VARCHAR},
    #{item.tenantId, jdbcType=VARCHAR},
    #{item.projectId, jdbcType=VARCHAR},
    #{item.createdTime, jdbcType=DATE},
    #{item.createdBy, jdbcType=VARCHAR},
    #{item.caseName, jdbcType=VARCHAR},
    #{item.caseNo, jdbcType=VARCHAR},
    #{item.caseType, jdbcType=INTEGER},
    #{item.isDelete, jdbcType=INTEGER},
      </trim>
    </foreach>
  </insert>

  <update id="updateByPrimaryKey" parameterType="net.northking.cctp.dw.db.entity.DwAtuCaseDesign">
    update
    <include refid="Table_Name"/>
    <set>
      <if test="tenantId != null">
        tenant_id = #{tenantId, jdbcType=VARCHAR},
      </if>
      <if test="projectId != null">
        project_id = #{projectId, jdbcType=VARCHAR},
      </if>
      <if test="createdTime != null">
        created_time = #{createdTime, jdbcType=DATE},
      </if>
      <if test="createdBy != null">
        created_by = #{createdBy, jdbcType=VARCHAR},
      </if>
      <if test="caseName != null">
        case_name = #{caseName, jdbcType=VARCHAR},
      </if>
      <if test="caseNo != null">
        case_no = #{caseNo, jdbcType=VARCHAR},
      </if>
      <if test="caseType != null">
        case_type = #{caseType, jdbcType=INTEGER},
      </if>
      <if test="isDelete != null">
        is_delete = #{isDelete, jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>

  <select id="query" resultMap="BaseResultMap" parameterType="net.northking.cctp.dw.db.entity.DwAtuCaseDesign">
    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="tenantId != null">
        AND tenant_id = #{tenantId,jdbcType=VARCHAR}
      </if>
      <if test="projectId != null">
        AND project_id = #{projectId,jdbcType=VARCHAR}
      </if>
      <if test="createdTime != null">
        AND created_time = #{createdTime,jdbcType=DATE}
      </if>
      <if test="createdBy != null">
        AND created_by = #{createdBy,jdbcType=VARCHAR}
      </if>
      <if test="caseName != null">
        AND case_name = #{caseName,jdbcType=VARCHAR}
      </if>
      <if test="caseNo != null">
        AND case_no = #{caseNo,jdbcType=VARCHAR}
      </if>
      <if test="caseType != null">
        AND case_type = #{caseType,jdbcType=INTEGER}
      </if>
      <if test="isDelete != null">
        AND is_delete = #{isDelete,jdbcType=INTEGER}
      </if>
    </trim>
  </select>

  <select id="queryCount" resultType="java.lang.Long" parameterType="net.northking.cctp.dw.db.entity.DwAtuCaseDesign">
    select count(*) from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id=#{id,jdbcType=VARCHAR}
      </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="createdTime != null">
        AND created_time=#{createdTime,jdbcType=DATE}
      </if>
      <if test="createdBy != null">
        AND created_by=#{createdBy,jdbcType=VARCHAR}
      </if>
      <if test="caseName != null">
        AND case_name=#{caseName,jdbcType=VARCHAR}
      </if>
      <if test="caseNo != null">
        AND case_no=#{caseNo,jdbcType=VARCHAR}
      </if>
      <if test="caseType != null">
        AND case_type=#{caseType,jdbcType=INTEGER}
      </if>
      <if test="isDelete != null">
        AND is_delete=#{isDelete,jdbcType=INTEGER}
      </if>
    </trim>
  </select>

</mapper>