<?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-11-23 15:54:59  -->
<mapper namespace="net.northking.cctp.testbug.db.dao.BugStatisticsChartDao">
  <resultMap id="BaseResultMap" type="net.northking.cctp.testbug.db.entity.BugStatisticsChart">
      <!--  -->
    <id column="id" jdbcType="VARCHAR" property="id"/>
                              <!-- 分配人 -->
    <result column="receiver_name" jdbcType="VARCHAR" property="receiverName"/>
        <!-- 模块 -->
    <result column="module_id" jdbcType="VARCHAR" property="moduleId"/>
        <!-- 分类: 0分配人，1模块 -->
    <result column="type" jdbcType="CHAR" property="type"/>
        <!-- 项目id -->
    <result column="project_id" jdbcType="VARCHAR" property="projectId"/>
        <!-- 缺陷状态 -->
    <result column="bug_status" jdbcType="VARCHAR" property="bugStatus"/>
        <!-- 缺陷状态码 -->
    <result column="bug_status_code" jdbcType="VARCHAR" property="bugStatusCode"/>
        <!--  -->
    <result column="amount" jdbcType="INTEGER" property="amount"/>
        <!-- 创建时间 -->
    <result column="create_time" jdbcType="VARCHAR" property="createTime"/>
        <!-- 租户id -->
    <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
    </resultMap>

  <sql id="Base_Column_List">
    id
    ,receiver_name
    ,module_id
    ,type
    ,project_id
    ,bug_status
    ,bug_status_code
    ,amount
    ,create_time
    ,tenant_id
  </sql>

  <sql id="Table_Name">
    ${defaultSchema}.bug_statistics_chart
  </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.testbug.db.entity.BugStatisticsChart">
    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="receiverName != null">
          AND receiver_name=#{receiverName,jdbcType=VARCHAR}
        </if>
              <if test="moduleId != null">
          AND module_id=#{moduleId,jdbcType=VARCHAR}
        </if>
              <if test="type != null">
          AND type=#{type,jdbcType=CHAR}
        </if>
              <if test="projectId != null">
          AND project_id=#{projectId,jdbcType=VARCHAR}
        </if>
              <if test="bugStatus != null">
          AND bug_status=#{bugStatus,jdbcType=VARCHAR}
        </if>
              <if test="bugStatusCode != null">
          AND bug_status_code=#{bugStatusCode,jdbcType=VARCHAR}
        </if>
              <if test="amount != null">
          AND amount=#{amount,jdbcType=INTEGER}
        </if>
              <if test="createTime != null">
          AND create_time=#{createTime,jdbcType=VARCHAR}
        </if>
              <if test="tenantId != null">
          AND tenant_id=#{tenantId,jdbcType=VARCHAR}
        </if>
          </trim>
  </delete>

  <insert id="insert" parameterType="net.northking.cctp.testbug.db.entity.BugStatisticsChart">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="receiverName != null">
        receiver_name,
      </if>
      <if test="moduleId != null">
        module_id,
      </if>
      <if test="type != null">
        type,
      </if>
      <if test="projectId != null">
        project_id,
      </if>
      <if test="bugStatus != null">
        bug_status,
      </if>
      <if test="bugStatusCode != null">
        bug_status_code,
      </if>
      <if test="amount != null">
        amount,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="tenantId != null">
        tenant_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
          #{id, jdbcType=VARCHAR},
      </if>
      <if test="receiverName != null">
          #{receiverName, jdbcType=VARCHAR},
      </if>
      <if test="moduleId != null">
          #{moduleId, jdbcType=VARCHAR},
      </if>
      <if test="type != null">
          #{type, jdbcType=CHAR},
      </if>
      <if test="projectId != null">
          #{projectId, jdbcType=VARCHAR},
      </if>
      <if test="bugStatus != null">
          #{bugStatus, jdbcType=VARCHAR},
      </if>
      <if test="bugStatusCode != null">
          #{bugStatusCode, jdbcType=VARCHAR},
      </if>
      <if test="amount != null">
          #{amount, jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
          #{createTime, jdbcType=VARCHAR},
      </if>
      <if test="tenantId != null">
          #{tenantId, jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>

  <insert id="insertByBatch" parameterType="java.util.List">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
    id,
    receiver_name,
    module_id,
    type,
    project_id,
    bug_status,
    bug_status_code,
    amount,
    create_time,
    tenant_id,
    </trim>
    values
    <foreach collection="list" item="item" index="index" separator=",">
      <trim prefix="(" suffix=")" suffixOverrides=",">
    #{item.id, jdbcType=VARCHAR},
    #{item.receiverName, jdbcType=VARCHAR},
    #{item.moduleId, jdbcType=VARCHAR},
    #{item.type, jdbcType=CHAR},
    #{item.projectId, jdbcType=VARCHAR},
    #{item.bugStatus, jdbcType=VARCHAR},
    #{item.bugStatusCode, jdbcType=VARCHAR},
    #{item.amount, jdbcType=INTEGER},
    #{item.createTime, jdbcType=VARCHAR},
    #{item.tenantId, jdbcType=VARCHAR},
      </trim>
    </foreach>
  </insert>

  <update id="updateByPrimaryKey" parameterType="net.northking.cctp.testbug.db.entity.BugStatisticsChart">
    update
    <include refid="Table_Name"/>
    <set>
      <if test="receiverName != null">
        receiver_name = #{receiverName, jdbcType=VARCHAR},
      </if>
      <if test="moduleId != null">
        module_id = #{moduleId, jdbcType=VARCHAR},
      </if>
      <if test="type != null">
        type = #{type, jdbcType=CHAR},
      </if>
      <if test="projectId != null">
        project_id = #{projectId, jdbcType=VARCHAR},
      </if>
      <if test="bugStatus != null">
        bug_status = #{bugStatus, jdbcType=VARCHAR},
      </if>
      <if test="bugStatusCode != null">
        bug_status_code = #{bugStatusCode, jdbcType=VARCHAR},
      </if>
      <if test="amount != null">
        amount = #{amount, jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        create_time = #{createTime, jdbcType=VARCHAR},
      </if>
      <if test="tenantId != null">
        tenant_id = #{tenantId, jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>

  <select id="query" resultMap="BaseResultMap" parameterType="net.northking.cctp.testbug.db.entity.BugStatisticsChart">
    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="receiverName != null">
        AND receiver_name = #{receiverName,jdbcType=VARCHAR}
      </if>
      <if test="moduleId != null">
        AND module_id = #{moduleId,jdbcType=VARCHAR}
      </if>
      <if test="type != null">
        AND type = #{type,jdbcType=CHAR}
      </if>
      <if test="projectId != null">
        AND project_id = #{projectId,jdbcType=VARCHAR}
      </if>
      <if test="bugStatus != null">
        AND bug_status = #{bugStatus,jdbcType=VARCHAR}
      </if>
      <if test="bugStatusCode != null">
        AND bug_status_code = #{bugStatusCode,jdbcType=VARCHAR}
      </if>
      <if test="amount != null">
        AND amount = #{amount,jdbcType=INTEGER}
      </if>
      <if test="createTime != null">
        AND create_time = #{createTime,jdbcType=VARCHAR}
      </if>
      <if test="tenantId != null">
        AND tenant_id = #{tenantId,jdbcType=VARCHAR}
      </if>
    </trim>
  </select>

  <select id="queryCount" resultType="java.lang.Long" parameterType="net.northking.cctp.testbug.db.entity.BugStatisticsChart">
    select count(*) from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id=#{id,jdbcType=VARCHAR}
      </if>
      <if test="receiverName != null">
        AND receiver_name=#{receiverName,jdbcType=VARCHAR}
      </if>
      <if test="moduleId != null">
        AND module_id=#{moduleId,jdbcType=VARCHAR}
      </if>
      <if test="type != null">
        AND type=#{type,jdbcType=CHAR}
      </if>
      <if test="projectId != null">
        AND project_id=#{projectId,jdbcType=VARCHAR}
      </if>
      <if test="bugStatus != null">
        AND bug_status=#{bugStatus,jdbcType=VARCHAR}
      </if>
      <if test="bugStatusCode != null">
        AND bug_status_code=#{bugStatusCode,jdbcType=VARCHAR}
      </if>
      <if test="amount != null">
        AND amount=#{amount,jdbcType=INTEGER}
      </if>
      <if test="createTime != null">
        AND create_time=#{createTime,jdbcType=VARCHAR}
      </if>
      <if test="tenantId != null">
        AND tenant_id=#{tenantId,jdbcType=VARCHAR}
      </if>
    </trim>
  </select>

</mapper>