<?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.DwAtuPlanInfoDao">
    <resultMap id="BaseResultMap" type="net.northking.cctp.dw.db.entity.DwAtuPlanInfo">
        <!--  -->
        <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="project_name" jdbcType="VARCHAR" property="projectName"/>

        <result column="plan_name" jdbcType="VARCHAR" property="planName"/>

        <result column="status" jdbcType="VARCHAR" property="status"/>
        <result column="manager_oper_code" jdbcType="VARCHAR" property="managerOperCode" />
        <result column="creator" jdbcType="VARCHAR" property="creator"/>
        <result column="created_by" jdbcType="VARCHAR" property="createdBy"/>
        <result column="plan_manager_company" jdbcType="VARCHAR" property="planManagerCompany" />

        <result column="plan_team_id" jdbcType="VARCHAR" property="planTeamId"/>
        <result column="plan_test_team" jdbcType="VARCHAR" property="planTestTeam"/>
        <result column="project_team_id" jdbcType="VARCHAR" property="projectTeamId"/>

        <result column="project_test_team" jdbcType="VARCHAR" property="projectTestTeam"/>

    </resultMap>

    <sql id="Base_Column_List">
        id
        ,tenant_id
        ,project_id
        ,project_name
        ,plan_name
        ,status
        ,creator
        ,created_by
        ,plan_team_id
        ,plan_test_team
        ,project_test_team
        ,project_team_id
        ,manager_oper_code
        ,plan_manager_company
    </sql>

    <sql id="Table_Name">
        ${defaultSchema}.dw_atu_plan_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.DwAtuPlanInfo">
        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="projectName != null">
                AND project_name=#{projectName,jdbcType=DATE}
            </if>
            <if test="planName != null">
                AND plan_name=#{planName,jdbcType=VARCHAR}
            </if>
            <if test="status != null">
                AND status=#{status,jdbcType=VARCHAR}
            </if>
            <if test="createdBy != null">
                AND created_by=#{createdBy,jdbcType=VARCHAR}
            </if>
            <if test="planTestTeam != null">
                AND plan_test_team=#{planTestTeam,jdbcType=VARCHAR}
            </if>
            <if test="projectTestTeam != null">
                AND project_test_team=#{projectTestTeam,jdbcType=VARCHAR}
            </if>
        </trim>
    </delete>

    <insert id="insert" parameterType="net.northking.cctp.dw.db.entity.DwAtuPlanInfo">
        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="projectName != null">
                project_name,
            </if>
            <if test="planName != null">
                plan_name,
            </if>
            <if test="status != null">
                status,
            </if>
            <if test="createdBy != null">
                created_by,
            </if>
            <if test="creator != null">
                creator,
            </if>
            <if test="planTeamId!=null">
                plan_team_id,
            </if>
            <if test="projectTeamId!=null">
                project_team_id,
            </if>
            <if test="planTestTeam!=null">
                plan_test_team,
            </if>
            <if test="projectTestTeam!=null">
                project_test_team,
            </if>
            <if test="createdTime!=null">
                created_time,
            </if>
            <if test="updatedTime!=null">
                updated_time,
            </if>
            <if test="hasCorn!=null">
                has_corn,
            </if>
            <if test="cronExpr!=null">
                cron_expr,
            </if>
            <if test="isDeleted!=null">
                is_deleted,
            </if>
            <if test="managerOperCode!=null">
                manager_oper_code,
            </if>
            <if test="planManagerCompany!=null">
                plan_manager_company,
            </if>
            <if test="isEnabled!=null">
                is_enabled,
            </if>
            <if test="updatedBy!=null">
                updated_by,
            </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="projectName != null">
                #{projectName, jdbcType=VARCHAR},
            </if>
            <if test="planName != null">
                #{planName, jdbcType=VARCHAR},
            </if>
            <if test="status != null">
                #{status, jdbcType=VARCHAR},
            </if>
            <if test="createdBy != null">
                #{createdBy, jdbcType=VARCHAR},
            </if>
            <if test="creator != null">
                #{creator, jdbcType=VARCHAR},
            </if>
            <if test="planTeamId!=null">
                #{planTeamId, jdbcType=VARCHAR},
            </if>
            <if test="projectTeamId!=null">
                #{projectTeamId, jdbcType=VARCHAR},
            </if>
            <if test="planTestTeam!=null">
                #{planTestTeam, jdbcType=VARCHAR},
            </if>
            <if test="projectTestTeam!=null">
                #{projectTestTeam, jdbcType=VARCHAR},
            </if>
            <if test="createdTime!=null">
                #{createdTime, jdbcType=TIMESTAMP},
            </if>
            <if test="updatedTime!=null">
                #{updatedTime, jdbcType=TIMESTAMP},
            </if>
            <if test="hasCorn!=null">
                #{hasCorn},
            </if>
            <if test="cronExpr!=null">
                #{cronExpr, jdbcType=VARCHAR},
            </if>
            <if test="isDeleted!=null">
                #{isDeleted},
            </if>
            <if test="managerOperCode!=null" >
                #{managerOperCode,jdbcType=VARCHAR},
            </if>
            <if test="planManagerCompany!=null">
                #{planManagerCompany,jdbcType=VARCHAR},
            </if>
            <if test="isEnabled!=null">
                #{isEnabled},
            </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
            ,tenant_id
            ,project_id
            ,project_name
            ,plan_name
            ,status
            ,created_by
            ,creator
            ,plan_team_id
            ,plan_test_team
            ,project_team_id
            ,project_test_team
            ,manager_oper_code
            ,plan_manager_company
        </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.projectName, jdbcType=VARCHAR},
                #{item.planName, jdbcType=VARCHAR},
                #{item.status, jdbcType=VARCHAR},
                #{item.createdBy, jdbcType=VARCHAR},
                #{item.creator, jdbcType=VARCHAR},
                #{item.planTeamId, jdbcType=VARCHAR},
                #{item.planTestTeam, jdbcType=VARCHAR},
                #{item.projectTeamId, jdbcType=VARCHAR},
                #{item.projectTestTeam, jdbcType=VARCHAR},
                #{item.managerOperCode, jdbcType=VARCHAR},
                #{item.planManagerCompany, jdbcType=VARCHAR},
            </trim>
        </foreach>
    </insert>

    <update id="updateByPrimaryKey" parameterType="net.northking.cctp.dw.db.entity.DwAtuPlanInfo">
        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="projectName != null">
                project_name = #{projectName, jdbcType=VARCHAR},
            </if>
            <if test="planName != null">
                plan_name = #{planName, jdbcType=VARCHAR},
            </if>
            <if test="status != null">
                status = #{status, jdbcType=VARCHAR},
            </if>
            <if test="createdBy != null">
                created_by = #{createdBy, jdbcType=VARCHAR},
            </if>
            <if test="planTestTeam != null">
                plan_test_team=#{planTestTeam,jdbcType=VARCHAR},
            </if>
            <if test="projectTestTeam != null">
                project_test_team=#{projectTestTeam,jdbcType=VARCHAR},
            </if>
            <if test="managerOperCode != null">
                manager_oper_code=#{managerOperCode, jdbcType=VARCHAR},
            </if>
        </set>
        where id = #{id,jdbcType=VARCHAR}
    </update>

    <select id="query" resultMap="BaseResultMap" parameterType="net.northking.cctp.dw.db.entity.DwAtuPlanInfo">
        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="projectName != null">
                AND project_name=#{projectName,jdbcType=DATE}
            </if>
            <if test="planName != null">
                AND plan_name=#{planName,jdbcType=VARCHAR}
            </if>
            <if test="status != null">
                AND status=#{status,jdbcType=VARCHAR}
            </if>
            <if test="createdBy != null">
                AND created_by=#{createdBy,jdbcType=VARCHAR}
            </if>
            <if test="planTestTeam != null">
                AND plan_test_team=#{planTestTeam,jdbcType=VARCHAR}
            </if>
            <if test="projectTestTeam != null">
                AND project_test_team=#{projectTestTeam,jdbcType=VARCHAR}
            </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="projectName != null">
                AND project_name=#{projectName,jdbcType=DATE}
            </if>
            <if test="planName != null">
                AND plan_name=#{planName,jdbcType=VARCHAR}
            </if>
            <if test="status != null">
                AND status=#{status,jdbcType=VARCHAR}
            </if>
            <if test="createdBy != null">
                AND created_by=#{createdBy,jdbcType=VARCHAR}
            </if>
            <if test="planTestTeam != null">
                AND plan_test_team=#{planTestTeam,jdbcType=VARCHAR}
            </if>
            <if test="projectTestTeam != null">
                AND project_test_team=#{projectTestTeam,jdbcType=VARCHAR}
            </if>
        </trim>
    </select>
    <select id="getPlanName" resultType="java.lang.String">
        select plan_name from dw_atu_plan_info where id = #{planId}
    </select>

</mapper>