<?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.DwAtuScriptInfoDao">
  <resultMap id="BaseResultMap" type="net.northking.cctp.dw.db.entity.DwAtuScriptInfo">
      <!--  -->
    <id column="id" jdbcType="VARCHAR" property="id"/>
                      <!--  -->
    <result column="script_type" jdbcType="INTEGER" property="scriptType"/>
        <!--  -->
    <result column="script_name" jdbcType="VARCHAR" property="scriptName"/>
        <!--  -->
    <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
        <!--  -->
    <result column="project_id" jdbcType="VARCHAR" property="projectId"/>
        <!--  -->
    <result column="is_deleted" jdbcType="INTEGER" property="isDeleted"/>

    <result column="script_manager" jdbcType="VARCHAR" property="scriptManager"/>
    <result column="test_team_manager" jdbcType="VARCHAR" property="testTeamManager"/>
    <result column="script_manager_oper_code" jdbcType="VARCHAR" property="scriptManagerOperCode"/>
    <result column="script_manager_company" jdbcType="VARCHAR" property="scriptManagerCompany"/>
    <result column="project_name" jdbcType="VARCHAR" property="projectName"/>
    <result column="test_team" jdbcType="VARCHAR" property="testTeam"/>
    <result column="test_team_id" jdbcType="VARCHAR" property="testTeamId"/>
    <result column="script_code" jdbcType="VARCHAR" property="scriptCode"/>

    </resultMap>

  <sql id="Base_Column_List">
    id
    ,script_type
    ,script_name
    ,tenant_id
    ,project_id
    ,is_deleted
  </sql>

  <sql id="Table_Name">
    ${defaultSchema}.dw_atu_script_info
  </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.DwAtuScriptInfo">
    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="scriptType != null">
          AND script_type=#{scriptType,jdbcType=INTEGER}
        </if>
              <if test="scriptName != null">
          AND script_name=#{scriptName,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="isDeleted != null">
          AND is_deleted=#{isDeleted,jdbcType=INTEGER}
        </if>
          </trim>
  </delete>

  <insert id="insert" parameterType="net.northking.cctp.dw.db.entity.DwAtuScriptInfo">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="scriptType != null">
        script_type,
      </if>
      <if test="scriptName != null">
        script_name,
      </if>
      <if test="tenantId != null">
        tenant_id,
      </if>
      <if test="projectId != null">
        project_id,
      </if>
      <if test="isDeleted != null">
        is_deleted,
      </if>
      <if test="scriptManager != null">
        script_manager,
      </if>
      <if test="testTeamManager != null">
        test_team_manager,
      </if>
      <if test="scriptManagerOperCode != null">
        script_manager_oper_code,
      </if>
      <if test="scriptManagerCompany != null">
        script_manager_company,
      </if>
      <if test="projectName != null">
        project_name,
      </if>
      <if test="testTeam != null">
        test_team,
      </if>
      <if test="testTeamId != null">
        test_team_id,
      </if>
      <if test="scriptCode != null">
        script_code,
      </if>
      <if test="createdTime!=null">
        created_time,
      </if>
      <if test="updatedTime!=null">
        updated_time,
      </if>
      <if test="scriptManagerId != null">
        script_manager_id,
      </if>
      <if test="updatedBy != null">
        updated_by,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
          #{id, jdbcType=VARCHAR},
      </if>
      <if test="scriptType != null">
          #{scriptType, jdbcType=INTEGER},
      </if>
      <if test="scriptName != null">
          #{scriptName, jdbcType=VARCHAR},
      </if>
      <if test="tenantId != null">
          #{tenantId, jdbcType=VARCHAR},
      </if>
      <if test="projectId != null">
          #{projectId, jdbcType=VARCHAR},
      </if>
      <if test="isDeleted != null">
          #{isDeleted, jdbcType=INTEGER},
      </if>
      <if test="scriptManager != null">
        #{scriptManager, jdbcType=VARCHAR},
      </if>
      <if test="testTeamManager != null">
        #{testTeamManager, jdbcType=VARCHAR},
      </if>
      <if test="scriptManagerOperCode != null">
        #{scriptManagerOperCode, jdbcType=VARCHAR},
      </if>
      <if test="scriptManagerCompany != null">
        #{scriptManagerCompany, jdbcType=VARCHAR},
      </if>
      <if test="projectName != null">
        #{projectName, jdbcType=VARCHAR},
      </if>
      <if test="testTeam != null">
        #{testTeam, jdbcType=VARCHAR},
      </if>
      <if test="testTeamId != null">
        #{testTeamId, jdbcType=VARCHAR},
      </if>
      <if test="scriptCode != null">
        #{scriptCode, jdbcType=VARCHAR},
      </if>
      <if test="createdTime!=null">
        #{createdTime},
      </if>
      <if test="updatedTime!=null">
        #{updatedTime},
      </if>
      <if test="scriptManagerId!=null">
        #{scriptManagerId},
      </if>
      <if test="updatedBy != null">
        #{updatedBy},
      </if>
    </trim>
  </insert>

  <insert id="insertByBatch" parameterType="java.util.List">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
    id,
    script_type,
    script_name,
    tenant_id,
    project_id,
    is_deleted,
    </trim>
    values
    <foreach collection="list" item="item" index="index" separator=",">
      <trim prefix="(" suffix=")" suffixOverrides=",">
    #{item.id, jdbcType=VARCHAR},
    #{item.scriptType, jdbcType=INTEGER},
    #{item.scriptName, jdbcType=VARCHAR},
    #{item.tenantId, jdbcType=VARCHAR},
    #{item.projectId, jdbcType=VARCHAR},
    #{item.isDeleted, jdbcType=INTEGER},
      </trim>
    </foreach>
  </insert>

  <update id="updateByPrimaryKey" parameterType="net.northking.cctp.dw.db.entity.DwAtuScriptInfo">
    update
    <include refid="Table_Name"/>
    <set>
      <if test="scriptType != null">
        script_type = #{scriptType, jdbcType=INTEGER},
      </if>
      <if test="scriptName != null">
        script_name = #{scriptName, jdbcType=VARCHAR},
      </if>
      <if test="tenantId != null">
        tenant_id = #{tenantId, jdbcType=VARCHAR},
      </if>
      <if test="projectId != null">
        project_id = #{projectId, jdbcType=VARCHAR},
      </if>
      <if test="isDeleted != null">
        is_deleted = #{isDeleted, jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>

  <select id="query" resultMap="BaseResultMap" parameterType="net.northking.cctp.dw.db.entity.DwAtuScriptInfo">
    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="scriptType != null">
        AND script_type = #{scriptType,jdbcType=INTEGER}
      </if>
      <if test="scriptName != null">
        AND script_name = #{scriptName,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="isDeleted != null">
        AND is_deleted = #{isDeleted,jdbcType=INTEGER}
      </if>
    </trim>
  </select>

  <select id="queryCount" resultType="java.lang.Long" parameterType="net.northking.cctp.dw.db.entity.DwAtuScriptInfo">
    select count(*) from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id=#{id,jdbcType=VARCHAR}
      </if>
      <if test="scriptType != null">
        AND script_type=#{scriptType,jdbcType=INTEGER}
      </if>
      <if test="scriptName != null">
        AND script_name=#{scriptName,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="isDeleted != null">
        AND is_deleted=#{isDeleted,jdbcType=INTEGER}
      </if>
    </trim>
  </select>

</mapper>