<?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 2021 . All rights reserved. -->
<!--  Mybatis数据库持久层（业务层映射文件）：缺陷条件搜索表 -->
<!--  version: 1.0  -->
<!--  author:  maven-cctp-plugin    -->
<!--  date:  2021-10-15 09:58:11  -->
<mapper namespace="net.northking.cctp.testbug.db.dao.BugSearchDao">


  <!-- 请在本文件内添加自定义SQL语句 -->

  <resultMap id="DetailMap" type="net.northking.cctp.testbug.dto.BugSearchDetailDto">
      <!--  -->
    <id column="id" jdbcType="VARCHAR" property="id"/>
        <!-- 自定义字段 -->
    <result column="expands" jdbcType="VARCHAR" property="expands"/>
        <!-- 项目-->
    <result column="pro_id" jdbcType="VARCHAR" property="proId"/>
        <!-- 租户id -->
    <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
        <!-- 搜索方案名称 -->
    <result column="scheme_name" jdbcType="VARCHAR" property="schemeName"/>
    <!-- 搜索方案名称 -->
    <result column="created_by" jdbcType="VARCHAR" property="createdBy"/>
    <!-- 创建时间 -->
    <result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
    <!-- 租户id -->
    <result column="updated_by" jdbcType="VARCHAR" property="updatedBy"/>
    <!-- 搜索方案名称 -->
    <result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime"/>
  </resultMap>

  <select id="pagingQuery" resultMap="DetailMap" parameterType="net.northking.cctp.testbug.dto.BugSearchQueryDto">
    select
    id
    ,expands
    ,pro_id
    ,tenant_id
    ,scheme_name
    ,created_by
    ,created_time
    ,updated_by
    ,updated_time
    from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null and id!=''">
        AND id = #{id,jdbcType=VARCHAR}
      </if>
      <if test="createdBy != null and createdBy!=''">
        AND created_by = #{createdBy,jdbcType=VARCHAR}
      </if>
      <if test="expands != null and expands!=''">
        AND expands = #{expands,jdbcType=LONGVARCHAR}
      </if>
      <if test="tenantId != null and tenantId!=''">
        AND tenant_id = #{tenantId,jdbcType=VARCHAR}
      </if>
      <if test="proId != null and proId!=''">
        AND pro_id = #{proId,jdbcType=VARCHAR}
      </if>
      <if test="schemeName != null and schemeName!=''">
        AND scheme_name = #{schemeName,jdbcType=VARCHAR}
      </if>
    </trim>
    order by created_time
  </select>
</mapper>