<?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-01-27 16:05:09  -->
<mapper namespace="net.northking.cctp.dw.db.dao.DwTestPointDao">
    <resultMap id="BaseResultMap" type="net.northking.cctp.dw.db.entity.DwTestPoint">
        <!-- id主键 -->
        <id column="id" jdbcType="VARCHAR" property="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="point_status" jdbcType="INTEGER" property="pointStatus"/>
    </resultMap>

    <sql id="Base_Column_List">
        id
        ,project_id
        ,created_by
        ,created_time
        ,tenant_id
        ,point_status
    </sql>

    <sql id="Table_Name">
        dw_test_point
    </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.lang.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.DwTestPoint">
        delete from
        <include refid="Table_Name"/>
        <trim prefix="WHERE" prefixOverrides="AND">
            <if test="id != null">
                AND id=#{id,jdbcType=VARCHAR}
            </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="pointStatus != null">
                AND point_status=#{pointStatus,jdbcType=INTEGER}
            </if>
        </trim>
    </delete>

    <insert id="insert" parameterType="net.northking.cctp.dw.db.entity.DwTestPoint">
        insert into
        <include refid="Table_Name"/>
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </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="pointStatus != null">
                point_status,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id, jdbcType=VARCHAR},
            </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="pointStatus != null">
                #{pointStatus, jdbcType=INTEGER},
            </if>
        </trim>
    </insert>

    <insert id="insertByBatch" parameterType="java.util.List">
        insert into
        <include refid="Table_Name"/>
        <trim prefix="(" suffix=")" suffixOverrides=",">
            id,
            project_id,
            created_by,
            created_time,
            tenant_id,
            point_status,
        </trim>
        values
        <foreach collection="list" item="item" index="index" separator=",">
            <trim prefix="(" suffix=")" suffixOverrides=",">
                #{item.id, jdbcType=VARCHAR},
                #{item.projectId, jdbcType=VARCHAR},
                #{item.createdBy, jdbcType=VARCHAR},
                #{item.createdTime, jdbcType=TIMESTAMP},
                #{item.tenantId, jdbcType=VARCHAR},
                #{item.pointStatus, jdbcType=INTEGER},
            </trim>
        </foreach>
    </insert>

    <update id="updateByPrimaryKey" parameterType="net.northking.cctp.dw.db.entity.DwTestPoint">
        update
        <include refid="Table_Name"/>
        <set>
            <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="pointStatus != null">
                point_status = #{pointStatus, jdbcType=INTEGER},
            </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.DwTestPoint">
        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="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="pointStatus != null">
                AND point_status = #{pointStatus,jdbcType=INTEGER}
            </if>
        </trim>
    </select>

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

</mapper>