<?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-03-22 15:07:11  -->
<mapper namespace="net.northking.cctp.dw.db.dao.DwManualExecDirDao">
    <resultMap id="BaseResultMap" type="net.northking.cctp.dw.db.entity.DwManualExecDir">
        <!--  -->
        <id column="id" jdbcType="VARCHAR" property="id"/>
        <!-- 目录名称 -->
        <result column="dir_name" jdbcType="VARCHAR" property="dirName"/>
        <!--  -->
        <result column="id_path" jdbcType="VARCHAR" property="idPath"/>
        <!--  -->
        <result column="name_path" jdbcType="VARCHAR" property="namePath"/>
        <!-- 目录层级 -->
        <result column="level_no" jdbcType="INTEGER" property="levelNo"/>
        <!-- 系统id -->
        <result column="project_id" jdbcType="VARCHAR" property="projectId"/>
        <!-- 创建人 -->
        <result column="created_by" jdbcType="VARCHAR" property="createdBy"/>
        <!-- 创建时间 -->
        <result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
        <!-- 租户id -->
        <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
        <!-- 逻辑删除(0-未删除,1-已删除) -->
        <result column="is_deleted" jdbcType="BIT" property="deleted"/>
    </resultMap>

    <sql id="Base_Column_List">
        id
        ,dir_name
        ,id_path
        ,name_path
        ,level_no
        ,project_id
        ,created_by
        ,created_time
        ,tenant_id
        ,is_deleted
    </sql>

    <sql id="Table_Name">
        dw_manual_exec_dir
    </sql>

    <select id="findByPrimaryKey" parameterType="java.lang.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="java.lang.String">
        delete from
        <include refid="Table_Name"/>
        where id = #{id,jdbcType=VARCHAR}
    </delete>

    <delete id="deleteByPrimaryKeys" parameterType="java.util.List">
        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.DwManualExecDir">
        delete from
        <include refid="Table_Name"/>
        <trim prefix="WHERE" prefixOverrides="AND">
            <if test="id != null">
                AND id=#{id,jdbcType=VARCHAR}
            </if>
            <if test="dirName != null">
                AND dir_name=#{dirName,jdbcType=VARCHAR}
            </if>
            <if test="idPath != null">
                AND id_path=#{idPath,jdbcType=VARCHAR}
            </if>
            <if test="namePath != null">
                AND name_path=#{namePath,jdbcType=VARCHAR}
            </if>
            <if test="levelNo != null">
                AND level_no=#{levelNo,jdbcType=INTEGER}
            </if>
            <if test="projectId != null">
                AND project_id=#{projectId,jdbcType=VARCHAR}
            </if>
            <if test="createdBy != null">
                AND created_by=#{createdBy,jdbcType=VARCHAR}
            </if>
            <if test="createdTime != null">
                AND created_time=#{createdTime,jdbcType=TIMESTAMP}
            </if>
            <if test="tenantId != null">
                AND tenant_id=#{tenantId,jdbcType=VARCHAR}
            </if>
            <if test="deleted != null">
                AND is_deleted=#{deleted,jdbcType=BIT}
            </if>
        </trim>
    </delete>

    <insert id="insert" parameterType="net.northking.cctp.dw.db.entity.DwManualExecDir">
        insert into
        <include refid="Table_Name"/>
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="dirName != null">
                dir_name,
            </if>
            <if test="idPath != null">
                id_path,
            </if>
            <if test="namePath != null">
                name_path,
            </if>
            <if test="levelNo != null">
                level_no,
            </if>
            <if test="projectId != null">
                project_id,
            </if>
            <if test="createdBy != null">
                created_by,
            </if>
            <if test="createdTime != null">
                created_time,
            </if>
            <if test="tenantId != null">
                tenant_id,
            </if>
            <if test="deleted != null">
                is_deleted,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id, jdbcType=VARCHAR},
            </if>
            <if test="dirName != null">
                #{dirName, jdbcType=VARCHAR},
            </if>
            <if test="idPath != null">
                #{idPath, jdbcType=VARCHAR},
            </if>
            <if test="namePath != null">
                #{namePath, jdbcType=VARCHAR},
            </if>
            <if test="levelNo != null">
                #{levelNo, jdbcType=INTEGER},
            </if>
            <if test="projectId != null">
                #{projectId, jdbcType=VARCHAR},
            </if>
            <if test="createdBy != null">
                #{createdBy, jdbcType=VARCHAR},
            </if>
            <if test="createdTime != null">
                #{createdTime, jdbcType=TIMESTAMP},
            </if>
            <if test="tenantId != null">
                #{tenantId, jdbcType=VARCHAR},
            </if>
            <if test="deleted != null">
                #{deleted, jdbcType=BIT},
            </if>
        </trim>
    </insert>

    <insert id="insertByBatch" parameterType="java.util.List">
        insert into
        <include refid="Table_Name"/>
        <trim prefix="(" suffix=")" suffixOverrides=",">
            id,
            dir_name,
            id_path,
            name_path,
            level_no,
            project_id,
            created_by,
            created_time,
            tenant_id,
            is_deleted,
        </trim>
        values
        <foreach collection="list" item="item" index="index" separator=",">
            <trim prefix="(" suffix=")" suffixOverrides=",">
                #{item.id, jdbcType=VARCHAR},
                #{item.dirName, jdbcType=VARCHAR},
                #{item.idPath, jdbcType=VARCHAR},
                #{item.namePath, jdbcType=VARCHAR},
                #{item.levelNo, jdbcType=INTEGER},
                #{item.projectId, jdbcType=VARCHAR},
                #{item.createdBy, jdbcType=VARCHAR},
                #{item.createdTime, jdbcType=TIMESTAMP},
                #{item.tenantId, jdbcType=VARCHAR},
                #{item.deleted, jdbcType=BIT},
            </trim>
        </foreach>
    </insert>

    <update id="updateByPrimaryKey" parameterType="net.northking.cctp.dw.db.entity.DwManualExecDir">
        update
        <include refid="Table_Name"/>
        <set>
            <if test="dirName != null">
                dir_name = #{dirName, jdbcType=VARCHAR},
            </if>
            <if test="idPath != null">
                id_path = #{idPath, jdbcType=VARCHAR},
            </if>
            <if test="namePath != null">
                name_path = #{namePath, jdbcType=VARCHAR},
            </if>
            <if test="levelNo != null">
                level_no = #{levelNo, jdbcType=INTEGER},
            </if>
            <if test="projectId != null">
                project_id = #{projectId, jdbcType=VARCHAR},
            </if>
            <if test="createdBy != null">
                created_by = #{createdBy, jdbcType=VARCHAR},
            </if>
            <if test="createdTime != null">
                created_time = #{createdTime, jdbcType=TIMESTAMP},
            </if>
            <if test="deleted != null">
                is_deleted = #{deleted, jdbcType=BIT},
            </if>
        </set>
        where id = #{id,jdbcType=VARCHAR}
        AND tenant_id = #{tenantId,jdbcType=VARCHAR}
    </update>

    <select id="query" resultMap="BaseResultMap" parameterType="net.northking.cctp.dw.db.entity.DwManualExecDir">
        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="dirName != null">
                AND dir_name = #{dirName,jdbcType=VARCHAR}
            </if>
            <if test="idPath != null">
                AND id_path = #{idPath,jdbcType=VARCHAR}
            </if>
            <if test="namePath != null">
                AND name_path = #{namePath,jdbcType=VARCHAR}
            </if>
            <if test="levelNo != null">
                AND level_no = #{levelNo,jdbcType=INTEGER}
            </if>
            <if test="projectId != null">
                AND project_id = #{projectId,jdbcType=VARCHAR}
            </if>
            <if test="createdBy != null">
                AND created_by = #{createdBy,jdbcType=VARCHAR}
            </if>
            <if test="createdTime != null">
                AND created_time = #{createdTime,jdbcType=TIMESTAMP}
            </if>
            <if test="tenantId != null">
                AND tenant_id = #{tenantId,jdbcType=VARCHAR}
            </if>
            <if test="deleted != null">
                AND is_deleted = #{deleted,jdbcType=BIT}
            </if>
        </trim>
    </select>

    <select id="queryCount" resultType="java.lang.Long" parameterType="net.northking.cctp.dw.db.entity.DwManualExecDir">
        select count(*) from
        <include refid="Table_Name"/>
        <trim prefix="WHERE" prefixOverrides="AND">
            <if test="id != null">
                AND id=#{id,jdbcType=VARCHAR}
            </if>
            <if test="dirName != null">
                AND dir_name=#{dirName,jdbcType=VARCHAR}
            </if>
            <if test="idPath != null">
                AND id_path=#{idPath,jdbcType=VARCHAR}
            </if>
            <if test="namePath != null">
                AND name_path=#{namePath,jdbcType=VARCHAR}
            </if>
            <if test="levelNo != null">
                AND level_no=#{levelNo,jdbcType=INTEGER}
            </if>
            <if test="projectId != null">
                AND project_id=#{projectId,jdbcType=VARCHAR}
            </if>
            <if test="createdBy != null">
                AND created_by=#{createdBy,jdbcType=VARCHAR}
            </if>
            <if test="createdTime != null">
                AND created_time=#{createdTime,jdbcType=TIMESTAMP}
            </if>
            <if test="tenantId != null">
                AND tenant_id=#{tenantId,jdbcType=VARCHAR}
            </if>
            <if test="deleted != null">
                AND is_deleted=#{deleted,jdbcType=BIT}
            </if>
        </trim>
    </select>

</mapper>