<?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-01-21 10:29:37  -->
<mapper namespace="net.northking.cctp.dw.db.dao.BugValidRepairRatioDao">
  <resultMap id="BaseResultMap" type="net.northking.cctp.dw.db.entity.BugValidRepairRatio">
      <!--  -->
    <id column="id" jdbcType="BIGINT" property="id"/>
                            <!-- 模块名 -->
    <result column="module_id" jdbcType="VARCHAR" property="moduleId"/>
        <!-- 有效缺陷数 -->
    <result column="valid" jdbcType="INTEGER" property="valid"/>
        <!-- 总缺陷数 -->
    <result column="bug_count" jdbcType="INTEGER" property="bugCount"/>
        <!-- 缺陷有效率 = 有效缺陷数(除无效状态之外的) / 缺陷总数 -->
    <result column="valid_ratio" jdbcType="VARCHAR" property="validRatio"/>
        <!-- 缺陷关闭数 -->
    <result column="bug_close" jdbcType="INTEGER" property="bugClose"/>
        <!-- 缺陷修复率 = 关闭缺陷数 / 有效缺陷数 -->
    <result column="repair_ratio" jdbcType="VARCHAR" property="repairRatio"/>
        <!-- 项目id -->
    <result column="project_id" jdbcType="VARCHAR" property="projectId"/>
        <!-- 租户id -->
    <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
    </resultMap>

  <sql id="Base_Column_List">
    id
    ,module_id
    ,valid
    ,bug_count
    ,valid_ratio
    ,bug_close
    ,repair_ratio
    ,project_id
    ,tenant_id
  </sql>

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

  <select id="findByPrimaryKey" parameterType="Long" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List"/>
    from
    <include refid="Table_Name"/>
    where id = #{id,jdbcType=BIGINT}
  </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=BIGINT}
    </foreach>
  </select>

  <delete id="deleteByPrimaryKey" parameterType="Long">
    delete from
    <include refid="Table_Name"/>
    where id = #{id,jdbcType=BIGINT}
  </delete>

  <delete id="deleteByPrimaryKeys" parameterType="Long">
    delete from
    <include refid="Table_Name"/>
    where id in
    <foreach collection="list" item="idItem" open="(" separator="," close=")">
      #{idItem, jdbcType=BIGINT}
    </foreach>
  </delete>

  <delete id="deleteByExample" parameterType="net.northking.cctp.dw.db.entity.BugValidRepairRatio">
    delete from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
          AND id=#{id,jdbcType=BIGINT}
      </if>
      <if test="moduleId != null">
          AND module_id=#{moduleId,jdbcType=VARCHAR}
      </if>
      <if test="valid != null">
          AND valid=#{valid,jdbcType=INTEGER}
      </if>
      <if test="bugCount != null">
          AND bug_count=#{bugCount,jdbcType=INTEGER}
      </if>
      <if test="validRatio != null">
          AND valid_ratio=#{validRatio,jdbcType=VARCHAR}
      </if>
      <if test="bugClose != null">
          AND bug_close=#{bugClose,jdbcType=INTEGER}
      </if>
      <if test="repairRatio != null">
          AND repair_ratio=#{repairRatio,jdbcType=VARCHAR}
      </if>
      <if test="projectId != null">
          AND project_id=#{projectId,jdbcType=VARCHAR}
      </if>
      <if test="tenantId != null">
          AND tenant_id=#{tenantId,jdbcType=VARCHAR}
      </if>
    </trim>
  </delete>

  <insert id="insert" parameterType="net.northking.cctp.dw.db.entity.BugValidRepairRatio">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="moduleId != null">
        module_id,
      </if>
      <if test="valid != null">
        valid,
      </if>
      <if test="bugCount != null">
        bug_count,
      </if>
      <if test="validRatio != null">
        valid_ratio,
      </if>
      <if test="bugClose != null">
        bug_close,
      </if>
      <if test="repairRatio != null">
        repair_ratio,
      </if>
      <if test="projectId != null">
        project_id,
      </if>
      <if test="tenantId != null">
        tenant_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
          #{id, jdbcType=BIGINT},
      </if>
      <if test="moduleId != null">
          #{moduleId, jdbcType=VARCHAR},
      </if>
      <if test="valid != null">
          #{valid, jdbcType=INTEGER},
      </if>
      <if test="bugCount != null">
          #{bugCount, jdbcType=INTEGER},
      </if>
      <if test="validRatio != null">
          #{validRatio, jdbcType=VARCHAR},
      </if>
      <if test="bugClose != null">
          #{bugClose, jdbcType=INTEGER},
      </if>
      <if test="repairRatio != null">
          #{repairRatio, jdbcType=VARCHAR},
      </if>
      <if test="projectId != null">
          #{projectId, 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,
    module_id,
    valid,
    bug_count,
    valid_ratio,
    bug_close,
    repair_ratio,
    project_id,
    tenant_id,
    </trim>
    values
    <foreach collection="list" item="item" index="index" separator=",">
      <trim prefix="(" suffix=")" suffixOverrides=",">
    #{item.id, jdbcType=BIGINT},
    #{item.moduleId, jdbcType=VARCHAR},
    #{item.valid, jdbcType=INTEGER},
    #{item.bugCount, jdbcType=INTEGER},
    #{item.validRatio, jdbcType=VARCHAR},
    #{item.bugClose, jdbcType=INTEGER},
    #{item.repairRatio, jdbcType=VARCHAR},
    #{item.projectId, jdbcType=VARCHAR},
    #{item.tenantId, jdbcType=VARCHAR},
      </trim>
    </foreach>
  </insert>

  <update id="updateByPrimaryKey" parameterType="net.northking.cctp.dw.db.entity.BugValidRepairRatio">
    update
    <include refid="Table_Name"/>
    <set>
      <if test="moduleId != null">
        module_id = #{moduleId, jdbcType=VARCHAR},
      </if>
      <if test="valid != null">
        valid = #{valid, jdbcType=INTEGER},
      </if>
      <if test="bugCount != null">
        bug_count = #{bugCount, jdbcType=INTEGER},
      </if>
      <if test="validRatio != null">
        valid_ratio = #{validRatio, jdbcType=VARCHAR},
      </if>
      <if test="bugClose != null">
        bug_close = #{bugClose, jdbcType=INTEGER},
      </if>
      <if test="repairRatio != null">
        repair_ratio = #{repairRatio, jdbcType=VARCHAR},
      </if>
      <if test="projectId != null">
        project_id = #{projectId, jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
    AND tenant_id = #{tenantId,jdbcType=VARCHAR}
  </update>

  <select id="query" resultMap="BaseResultMap" parameterType="net.northking.cctp.dw.db.entity.BugValidRepairRatio">
    select
    <include refid="Base_Column_List" />
    from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id = #{id,jdbcType=BIGINT}
      </if>
      <if test="moduleId != null">
        AND module_id = #{moduleId,jdbcType=VARCHAR}
      </if>
      <if test="valid != null">
        AND valid = #{valid,jdbcType=INTEGER}
      </if>
      <if test="bugCount != null">
        AND bug_count = #{bugCount,jdbcType=INTEGER}
      </if>
      <if test="validRatio != null">
        AND valid_ratio = #{validRatio,jdbcType=VARCHAR}
      </if>
      <if test="bugClose != null">
        AND bug_close = #{bugClose,jdbcType=INTEGER}
      </if>
      <if test="repairRatio != null">
        AND repair_ratio = #{repairRatio,jdbcType=VARCHAR}
      </if>
      <if test="projectId != null">
        AND project_id = #{projectId,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.dw.db.entity.BugValidRepairRatio">
    select count(*) from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id=#{id,jdbcType=BIGINT}
      </if>
      <if test="moduleId != null">
        AND module_id=#{moduleId,jdbcType=VARCHAR}
      </if>
      <if test="valid != null">
        AND valid=#{valid,jdbcType=INTEGER}
      </if>
      <if test="bugCount != null">
        AND bug_count=#{bugCount,jdbcType=INTEGER}
      </if>
      <if test="validRatio != null">
        AND valid_ratio=#{validRatio,jdbcType=VARCHAR}
      </if>
      <if test="bugClose != null">
        AND bug_close=#{bugClose,jdbcType=INTEGER}
      </if>
      <if test="repairRatio != null">
        AND repair_ratio=#{repairRatio,jdbcType=VARCHAR}
      </if>
      <if test="projectId != null">
        AND project_id=#{projectId,jdbcType=VARCHAR}
      </if>
      <if test="tenantId != null">
        AND tenant_id=#{tenantId,jdbcType=VARCHAR}
      </if>
    </trim>
  </select>

</mapper>