<?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数据库持久层（底层映射文件）：dw脚本版本同步表 -->
<!--  version: 1.0  -->
<!--  author:  maven-cctp-plugin    -->
<!--  date:  2022-11-25 11:15:20  -->
<mapper namespace="net.northking.cctp.dw.db.dao.DwAtuScriptVersionDao">
  <resultMap id="BaseResultMap" type="net.northking.cctp.dw.db.entity.DwAtuScriptVersion">
        <!--  -->
    <id column="version_id" jdbcType="INTEGER" property="versionId"/>
            <!--  -->
    <result column="script_id" jdbcType="VARCHAR" property="scriptId"/>
            <!--  -->
    <result column="created_by" jdbcType="VARCHAR" property="createdBy"/>
        <!--  -->
    <result column="created_time" jdbcType="DATE" property="createdTime"/>
    </resultMap>

  <sql id="Base_Column_List">
    script_id
    ,version_id
    ,created_by
    ,created_time
  </sql>

  <sql id="Table_Name">
    ${defaultSchema}.dw_atu_script_version
  </sql>

  <select id="findByPrimaryKey" parameterType="Integer" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List"/>
    from
    <include refid="Table_Name"/>
    where version_id = #{versionId,jdbcType=INTEGER}
  </select>

  <select id="findByPrimaryKeys" parameterType="java.util.List">
    select
    <include refid="Base_Column_List"/>
    from
    <include refid="Table_Name"/>
    where version_id in
    <foreach collection="list" item="idItem" open="(" separator="," close=")">
      #{idItem, jdbcType=INTEGER}
    </foreach>
  </select>

  <delete id="deleteByPrimaryKey" parameterType="Integer">
    delete from
    <include refid="Table_Name"/>
    where version_id = #{versionId,jdbcType=INTEGER}
  </delete>

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

  <delete id="deleteByExample" parameterType="net.northking.cctp.dw.db.entity.DwAtuScriptVersion">
    delete from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <choose>
        <when test="versionId != null">
          version_id = #{versionId,jdbcType=INTEGER}
        </when>
      </choose>
              <if test="scriptId != null">
          AND script_id=#{scriptId,jdbcType=VARCHAR}
        </if>
              <if test="versionId != null">
          AND version_id=#{versionId,jdbcType=INTEGER}
        </if>
              <if test="createdBy != null">
          AND created_by=#{createdBy,jdbcType=VARCHAR}
        </if>
              <if test="createdTime != null">
          AND created_time=#{createdTime,jdbcType=DATE}
        </if>
          </trim>
  </delete>

  <insert id="insert" parameterType="net.northking.cctp.dw.db.entity.DwAtuScriptVersion">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="scriptId != null">
        script_id,
      </if>
      <if test="versionId != null">
        version_id,
      </if>
      <if test="createdBy != null">
        created_by,
      </if>
      <if test="createdTime != null">
        created_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="scriptId != null">
          #{scriptId, jdbcType=VARCHAR},
      </if>
      <if test="versionId != null">
          #{versionId, jdbcType=INTEGER},
      </if>
      <if test="createdBy != null">
          #{createdBy, jdbcType=VARCHAR},
      </if>
      <if test="createdTime != null">
          #{createdTime, jdbcType=DATE},
      </if>
    </trim>
  </insert>

  <insert id="insertByBatch" parameterType="java.util.List">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
    script_id,
    version_id,
    created_by,
    created_time,
    </trim>
    values
    <foreach collection="list" item="item" index="index" separator=",">
      <trim prefix="(" suffix=")" suffixOverrides=",">
    #{item.scriptId, jdbcType=VARCHAR},
    #{item.versionId, jdbcType=INTEGER},
    #{item.createdBy, jdbcType=VARCHAR},
    #{item.createdTime, jdbcType=DATE},
      </trim>
    </foreach>
  </insert>

  <update id="updateByPrimaryKey" parameterType="net.northking.cctp.dw.db.entity.DwAtuScriptVersion">
    update
    <include refid="Table_Name"/>
    <set>
      <if test="scriptId != null">
        script_id = #{scriptId, jdbcType=VARCHAR},
      </if>
      <if test="createdBy != null">
        created_by = #{createdBy, jdbcType=VARCHAR},
      </if>
      <if test="createdTime != null">
        created_time = #{createdTime, jdbcType=DATE},
      </if>
    </set>
    where version_id = #{versionId,jdbcType=INTEGER}
  </update>

  <select id="query" resultMap="BaseResultMap" parameterType="net.northking.cctp.dw.db.entity.DwAtuScriptVersion">
    select
    <include refid="Base_Column_List" />
    from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="scriptId != null">
        AND script_id = #{scriptId,jdbcType=VARCHAR}
      </if>
      <if test="versionId != null">
        AND version_id = #{versionId,jdbcType=INTEGER}
      </if>
      <if test="createdBy != null">
        AND created_by = #{createdBy,jdbcType=VARCHAR}
      </if>
      <if test="createdTime != null">
        AND created_time = #{createdTime,jdbcType=DATE}
      </if>
    </trim>
  </select>

  <select id="queryCount" resultType="java.lang.Long" parameterType="net.northking.cctp.dw.db.entity.DwAtuScriptVersion">
    select count(*) from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="scriptId != null">
        AND script_id=#{scriptId,jdbcType=VARCHAR}
      </if>
      <if test="versionId != null">
        AND version_id=#{versionId,jdbcType=INTEGER}
      </if>
      <if test="createdBy != null">
        AND created_by=#{createdBy,jdbcType=VARCHAR}
      </if>
      <if test="createdTime != null">
        AND created_time=#{createdTime,jdbcType=DATE}
      </if>
    </trim>
  </select>

</mapper>