<?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.DwAtuPlanEnvLinkDao">
    <resultMap id="BaseResultMap" type="net.northking.cctp.dw.db.entity.DwAtuPlanEnvLink">
        <!--  -->
        <id column="id" jdbcType="VARCHAR" property="id"/>
        <!--  -->
        <result column="env_name" jdbcType="VARCHAR" property="envName"/>
        <!--  -->
        <result column="env_id" jdbcType="VARCHAR" property="envId"/>
        <!--  -->
        <result column="plan_id" jdbcType="VARCHAR" property="planId"/>

        <result column="sort" jdbcType="INTEGER" property="sort"/>

    </resultMap>

    <sql id="Base_Column_List">
        id
        ,plan_id
        ,env_id
        ,env_name
        ,sort
    </sql>

    <sql id="Table_Name">
        ${defaultSchema}.dw_atu_plan_env_link
    </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.DwAtuPlanEnvLink">
        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="sort != null">
                AND sort=#{sort,jdbcType=INTEGER}
            </if>

            <if test="planId != null">
                AND plant_id=#{planId,jdbcType=VARCHAR}
            </if>
            <if test="envId != null">
                AND env_id=#{envId,jdbcType=VARCHAR}
            </if>
            <if test="envName != null">
                AND env_name=#{envName,jdbcType=VARCHAR}
            </if>

        </trim>
    </delete>

    <insert id="insert" parameterType="net.northking.cctp.dw.db.entity.DwAtuPlanEnvLink">
        insert into
        <include refid="Table_Name"/>
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="sort != null">
                sort,
            </if>
            <if test="envId != null">
                env_id,
            </if>
            <if test="envName != null">
                env_name,
            </if>
            <if test="planId != null">
                plan_id,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id, jdbcType=VARCHAR},
            </if>
            <if test="sort != null">
                #{sort, jdbcType=INTEGER},
            </if>
            <if test="envId != null">
                #{envId, jdbcType=VARCHAR},
            </if>
            <if test="envName != null">
                #{envName, jdbcType=VARCHAR},
            </if>
            <if test="planId != null">
                #{planId, jdbcType=VARCHAR},
            </if>

        </trim>
    </insert>

    <insert id="insertByBatch" parameterType="java.util.List">
        insert into
        <include refid="Table_Name"/>
        <trim prefix="(" suffix=")" suffixOverrides=",">
            id,
            env_id,
            env_name,
            sort,
            plan_id,
        </trim>
        values
        <foreach collection="list" item="item" index="index" separator=",">
            <trim prefix="(" suffix=")" suffixOverrides=",">
                #{item.id, jdbcType=VARCHAR},
                #{item.sort, jdbcType=INTEGER},
                #{item.envId, jdbcType=VARCHAR},
                #{item.envName, jdbcType=VARCHAR},
                #{item.planId, jdbcType=VARCHAR},
            </trim>
        </foreach>
    </insert>

    <update id="updateByPrimaryKey" parameterType="net.northking.cctp.dw.db.entity.DwAtuPlanEnvLink">
        update
        <include refid="Table_Name"/>
        <set>
            <if test="sort != null">
                sort = #{sort, jdbcType=INTEGER},
            </if>
            <if test="envId != null">
                env_id = #{envId, jdbcType=VARCHAR},
            </if>
            <if test="envName != null">
                env_name = #{envName, jdbcType=VARCHAR},
            </if>
            <if test="planId != null">
                plan_id = #{planId, jdbcType=VARCHAR},
            </if>

        </set>
        where id = #{id,jdbcType=VARCHAR}
    </update>

    <select id="query" resultMap="BaseResultMap" parameterType="net.northking.cctp.dw.db.entity.DwAtuPlanEnvLink">
        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="sort != null">
                AND sort = #{sort,jdbcType=INTEGER}
            </if>
            <if test="envId != null">
                AND env_id = #{envId,jdbcType=VARCHAR}
            </if>
            <if test="envName != null">
                AND env_name = #{envName,jdbcType=VARCHAR}
            </if>
            <if test="planId != null">
                AND plan_id = #{planId,jdbcType=VARCHAR}
            </if>

        </trim>
    </select>

    <select id="queryCount" resultType="java.lang.Long" parameterType="net.northking.cctp.dw.db.entity.DwAtuPlanEnvLink">
        select count(*) from
        <include refid="Table_Name"/>
        <trim prefix="WHERE" prefixOverrides="AND">
            <if test="id != null">
                AND id=#{id,jdbcType=VARCHAR}
            </if>
            <if test="sort != null">
                AND sort=#{sort,jdbcType=INTEGER}
            </if>
            <if test="envId != null">
                AND env_id=#{envId,jdbcType=VARCHAR}
            </if>
            <if test="envName != null">
                AND env_name=#{envName,jdbcType=VARCHAR}
            </if>
            <if test="planId != null">
                AND plan_id=#{planId,jdbcType=VARCHAR}
            </if>
        </trim>
    </select>

</mapper>