<?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-15 18:07:56  -->
<mapper namespace="net.northking.cctp.testbug.db.dao.BugOverallTendencyChartDao">
  <resultMap id="BaseResultMap" type="net.northking.cctp.testbug.db.entity.BugOverallTendencyChart">
      <!--  -->
    <id column="id" jdbcType="VARCHAR" property="id"/>
                      <!-- 租户id -->
    <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
        <!-- 创建时间 -->
    <result column="created_time" jdbcType="DATE" property="createdTime"/>
        <!-- 未解决 -->
    <result column="unsolved" jdbcType="INTEGER" property="unsolved"/>
        <!-- 已解决 -->
    <result column="solved" jdbcType="INTEGER" property="solved"/>
        <!-- 所有 -->
    <result column="all" jdbcType="INTEGER" property="all"/>
        <!-- 项目id -->
    <result column="pro_id" jdbcType="VARCHAR" property="proId"/>
        <!-- 记录类型 -->
    <result column="record_type" jdbcType="INTEGER" property="recordType"/>
    </resultMap>

  <sql id="Base_Column_List">
    id
    ,tenant_id
    ,created_time
    ,unsolved
    ,solved
    ,all
    ,pro_id
    ,record_type
  </sql>

  <sql id="Table_Name">
    ${defaultSchema}.bug_overall_tendency_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.BugOverallTendencyChart">
    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="tenantId != null">
          AND tenant_id=#{tenantId,jdbcType=VARCHAR}
        </if>
              <if test="createdTime != null">
          AND created_time=#{createdTime,jdbcType=DATE}
        </if>
              <if test="unsolved != null">
          AND unsolved=#{unsolved,jdbcType=INTEGER}
        </if>
              <if test="solved != null">
          AND solved=#{solved,jdbcType=INTEGER}
        </if>
              <if test="all != null">
          AND all=#{all,jdbcType=INTEGER}
        </if>
              <if test="proId != null">
          AND pro_id=#{proId,jdbcType=VARCHAR}
        </if>
              <if test="recordType != null">
          AND record_type=#{recordType,jdbcType=INTEGER}
        </if>
          </trim>
  </delete>

  <insert id="insert" parameterType="net.northking.cctp.testbug.db.entity.BugOverallTendencyChart">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="tenantId != null">
        tenant_id,
      </if>
      <if test="createdTime != null">
        created_time,
      </if>
      <if test="unsolved != null">
        unsolved,
      </if>
      <if test="solved != null">
        solved,
      </if>
      <if test="all != null">
        `all`,
      </if>
      <if test="proId != null">
        pro_id,
      </if>
      <if test="recordType != null">
        record_type,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
          #{id, jdbcType=VARCHAR},
      </if>
      <if test="tenantId != null">
          #{tenantId, jdbcType=VARCHAR},
      </if>
      <if test="createdTime != null">
          #{createdTime, jdbcType=DATE},
      </if>
      <if test="unsolved != null">
          #{unsolved, jdbcType=INTEGER},
      </if>
      <if test="solved != null">
          #{solved, jdbcType=INTEGER},
      </if>
      <if test="all != null">
          #{all, jdbcType=INTEGER},
      </if>
      <if test="proId != null">
        #{proId, jdbcType=VARCHAR},
      </if>
      <if test="recordType != null">
        #{recordType, jdbcType=INTEGER},
      </if>
    </trim>
  </insert>

  <insert id="insertByBatch" parameterType="java.util.List">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
    id,
    tenant_id,
    created_time,
    unsolved,
    solved,
    all,
      pro_id,
      record_type,
    </trim>
    values
    <foreach collection="list" item="item" index="index" separator=",">
      <trim prefix="(" suffix=")" suffixOverrides=",">
    #{item.id, jdbcType=VARCHAR},
    #{item.tenantId, jdbcType=VARCHAR},
    #{item.createdTime, jdbcType=DATE},
    #{item.unsolved, jdbcType=INTEGER},
    #{item.solved, jdbcType=INTEGER},
    #{item.all, jdbcType=INTEGER},
        #{item.proId, jdbcType=VARCHAR},
        #{item.recordType, jdbcType=INTEGER},
      </trim>
    </foreach>
  </insert>

  <update id="updateByPrimaryKey" parameterType="net.northking.cctp.testbug.db.entity.BugOverallTendencyChart">
    update
    <include refid="Table_Name"/>
    <set>
      <if test="tenantId != null">
        tenant_id = #{tenantId, jdbcType=VARCHAR},
      </if>
      <if test="createdTime != null">
        created_time = #{createdTime, jdbcType=DATE},
      </if>
      <if test="unsolved != null">
        unsolved = #{unsolved, jdbcType=INTEGER},
      </if>
      <if test="solved != null">
        solved = #{solved, jdbcType=INTEGER},
      </if>
      <if test="all != null">
        all = #{all, jdbcType=INTEGER},
      </if>
      <if test="proId != null">
        pro_id = #{proId, jdbcType=VARCHAR},
      </if>
      <if test="recordType != null">
        record_type = #{recordType, jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>

  <select id="query" resultMap="BaseResultMap" parameterType="net.northking.cctp.testbug.db.entity.BugOverallTendencyChart">
    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="tenantId != null">
        AND tenant_id = #{tenantId,jdbcType=VARCHAR}
      </if>
      <if test="createdTime != null">
        AND created_time = #{createdTime,jdbcType=DATE}
      </if>
      <if test="unsolved != null">
        AND unsolved = #{unsolved,jdbcType=INTEGER}
      </if>
      <if test="solved != null">
        AND solved = #{solved,jdbcType=INTEGER}
      </if>
      <if test="all != null">
        AND all = #{all,jdbcType=INTEGER}
      </if>
      <if test="proId != null">
        AND pro_id = #{proId,jdbcType=VARCHAR}
      </if>
      <if test="recordType != null">
        AND record_type = #{recordType,jdbcType=INTEGER}
      </if>
    </trim>
  </select>

  <select id="queryCount" resultType="java.lang.Long" parameterType="net.northking.cctp.testbug.db.entity.BugOverallTendencyChart">
    select count(*) from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id=#{id,jdbcType=VARCHAR}
      </if>
      <if test="tenantId != null">
        AND tenant_id=#{tenantId,jdbcType=VARCHAR}
      </if>
      <if test="createdTime != null">
        AND created_time=#{createdTime,jdbcType=DATE}
      </if>
      <if test="unsolved != null">
        AND unsolved=#{unsolved,jdbcType=INTEGER}
      </if>
      <if test="solved != null">
        AND solved=#{solved,jdbcType=INTEGER}
      </if>
      <if test="all != null">
        AND all=#{all,jdbcType=INTEGER}
      </if>
      <if test="proId != null">
        AND pro_id = #{proId,jdbcType=VARCHAR}
      </if>
      <if test="recordType != null">
        AND record_type = #{recordType,jdbcType=INTEGER}
      </if>
    </trim>
  </select>

</mapper>