<?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.BugLegacyGradeDao">
  <resultMap id="BaseResultMap" type="net.northking.cctp.dw.db.entity.BugLegacyGrade">
      <!--  -->
    <id column="id" jdbcType="BIGINT" property="id"/>
                            <!-- 模块 -->
    <result column="module_id" jdbcType="VARCHAR" property="moduleId"/>
        <!-- 致命性错误-A类 -->
    <result column="grade_a" jdbcType="INTEGER" property="gradeA"/>
        <!-- 严重性错误-B类 -->
    <result column="grade_b" jdbcType="INTEGER" property="gradeB"/>
        <!-- 一般性错误-C类 -->
    <result column="grade_c" jdbcType="INTEGER" property="gradeC"/>
        <!-- 警告性错误-D类 -->
    <result column="grade_d" jdbcType="INTEGER" property="gradeD"/>
        <!-- 建议性错误-E类 -->
    <result column="grade_e" jdbcType="INTEGER" property="gradeE"/>
        <!-- 项目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
    ,grade_a
    ,grade_b
    ,grade_c
    ,grade_d
    ,grade_e
    ,project_id
    ,tenant_id
  </sql>

  <sql id="Table_Name">
    bug_legacy_grade
  </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.BugLegacyGrade">
    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="gradeA != null">
          AND grade_a=#{gradeA,jdbcType=INTEGER}
      </if>
      <if test="gradeB != null">
          AND grade_b=#{gradeB,jdbcType=INTEGER}
      </if>
      <if test="gradeC != null">
          AND grade_c=#{gradeC,jdbcType=INTEGER}
      </if>
      <if test="gradeD != null">
          AND grade_d=#{gradeD,jdbcType=INTEGER}
      </if>
      <if test="gradeE != null">
          AND grade_e=#{gradeE,jdbcType=INTEGER}
      </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.BugLegacyGrade">
    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="gradeA != null">
        grade_a,
      </if>
      <if test="gradeB != null">
        grade_b,
      </if>
      <if test="gradeC != null">
        grade_c,
      </if>
      <if test="gradeD != null">
        grade_d,
      </if>
      <if test="gradeE != null">
        grade_e,
      </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="gradeA != null">
          #{gradeA, jdbcType=INTEGER},
      </if>
      <if test="gradeB != null">
          #{gradeB, jdbcType=INTEGER},
      </if>
      <if test="gradeC != null">
          #{gradeC, jdbcType=INTEGER},
      </if>
      <if test="gradeD != null">
          #{gradeD, jdbcType=INTEGER},
      </if>
      <if test="gradeE != null">
          #{gradeE, jdbcType=INTEGER},
      </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,
    grade_a,
    grade_b,
    grade_c,
    grade_d,
    grade_e,
    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.gradeA, jdbcType=INTEGER},
    #{item.gradeB, jdbcType=INTEGER},
    #{item.gradeC, jdbcType=INTEGER},
    #{item.gradeD, jdbcType=INTEGER},
    #{item.gradeE, jdbcType=INTEGER},
    #{item.projectId, jdbcType=VARCHAR},
    #{item.tenantId, jdbcType=VARCHAR},
      </trim>
    </foreach>
  </insert>

  <update id="updateByPrimaryKey" parameterType="net.northking.cctp.dw.db.entity.BugLegacyGrade">
    update
    <include refid="Table_Name"/>
    <set>
      <if test="moduleId != null">
        module_id = #{moduleId, jdbcType=VARCHAR},
      </if>
      <if test="gradeA != null">
        grade_a = #{gradeA, jdbcType=INTEGER},
      </if>
      <if test="gradeB != null">
        grade_b = #{gradeB, jdbcType=INTEGER},
      </if>
      <if test="gradeC != null">
        grade_c = #{gradeC, jdbcType=INTEGER},
      </if>
      <if test="gradeD != null">
        grade_d = #{gradeD, jdbcType=INTEGER},
      </if>
      <if test="gradeE != null">
        grade_e = #{gradeE, jdbcType=INTEGER},
      </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.BugLegacyGrade">
    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="gradeA != null">
        AND grade_a = #{gradeA,jdbcType=INTEGER}
      </if>
      <if test="gradeB != null">
        AND grade_b = #{gradeB,jdbcType=INTEGER}
      </if>
      <if test="gradeC != null">
        AND grade_c = #{gradeC,jdbcType=INTEGER}
      </if>
      <if test="gradeD != null">
        AND grade_d = #{gradeD,jdbcType=INTEGER}
      </if>
      <if test="gradeE != null">
        AND grade_e = #{gradeE,jdbcType=INTEGER}
      </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.BugLegacyGrade">
    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="gradeA != null">
        AND grade_a=#{gradeA,jdbcType=INTEGER}
      </if>
      <if test="gradeB != null">
        AND grade_b=#{gradeB,jdbcType=INTEGER}
      </if>
      <if test="gradeC != null">
        AND grade_c=#{gradeC,jdbcType=INTEGER}
      </if>
      <if test="gradeD != null">
        AND grade_d=#{gradeD,jdbcType=INTEGER}
      </if>
      <if test="gradeE != null">
        AND grade_e=#{gradeE,jdbcType=INTEGER}
      </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>