<?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-12-15 11:38:02  -->
<mapper namespace="net.northking.cctp.testbug.db.dao.OverallViewIndexDao">
  <resultMap id="BaseResultMap" type="net.northking.cctp.testbug.db.entity.OverallViewIndex">
      <!--  -->
    <id column="id" jdbcType="VARCHAR" property="id"/>
                <!-- 项目id集合 -->
    <result column="pro_id_list" jdbcType="VARCHAR" property="proIdList"/>
        <!-- 用户id -->
    <result column="user_id" jdbcType="VARCHAR" property="userId"/>
        <!-- 记录类型 -->
    <result column="record_type" jdbcType="VARCHAR" property="recordType"/>
    </resultMap>

  <sql id="Base_Column_List">
    id
    ,pro_id_list
    ,user_id
    ,record_type
  </sql>

  <sql id="Table_Name">
    ${defaultSchema}.overall_view_index
  </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.OverallViewIndex">
    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="proIdList != null">
          AND pro_id_list=#{proIdList,jdbcType=VARCHAR}
        </if>
              <if test="userId != null">
          AND user_id=#{userId,jdbcType=VARCHAR}
        </if>
      <if test="recordType != null">
        AND record_type=#{recordType,jdbcType=VARCHAR}
      </if>
          </trim>
  </delete>

  <insert id="insert" parameterType="net.northking.cctp.testbug.db.entity.OverallViewIndex">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="proIdList != null">
        pro_id_list,
      </if>
      <if test="userId != null">
        user_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="proIdList != null">
          #{proIdList, jdbcType=VARCHAR},
      </if>
      <if test="userId != null">
          #{userId, jdbcType=VARCHAR},
      </if>
      <if test="recordType != null">
        #{recordType, jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>

  <insert id="insertByBatch" parameterType="java.util.List">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
    id,
    pro_id_list,
    user_id,
      record_type,
    </trim>
    values
    <foreach collection="list" item="item" index="index" separator=",">
      <trim prefix="(" suffix=")" suffixOverrides=",">
    #{item.id, jdbcType=VARCHAR},
    #{item.proIdList, jdbcType=VARCHAR},
    #{item.userId, jdbcType=VARCHAR},
        #{item.recordType, jdbcType=VARCHAR},
      </trim>
    </foreach>
  </insert>

  <update id="updateByPrimaryKey" parameterType="net.northking.cctp.testbug.db.entity.OverallViewIndex">
    update
    <include refid="Table_Name"/>
    <set>
      <if test="proIdList != null">
        pro_id_list = #{proIdList, jdbcType=VARCHAR},
      </if>
      <if test="userId != null">
        user_id = #{userId, jdbcType=VARCHAR},
      </if>
      <if test="recordType != null">
        record_type=#{recordType, jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>

  <select id="query" resultMap="BaseResultMap" parameterType="net.northking.cctp.testbug.db.entity.OverallViewIndex">
    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="proIdList != null">
        AND pro_id_list = #{proIdList,jdbcType=VARCHAR}
      </if>
      <if test="userId != null">
        AND user_id = #{userId,jdbcType=VARCHAR}
      </if>
      <if test="recordType != null">
        AND record_type = #{recordType,jdbcType=VARCHAR}
      </if>
    </trim>
  </select>

  <select id="queryCount" resultType="java.lang.Long" parameterType="net.northking.cctp.testbug.db.entity.OverallViewIndex">
    select count(*) from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id=#{id,jdbcType=VARCHAR}
      </if>
      <if test="proIdList != null">
        AND pro_id_list=#{proIdList,jdbcType=VARCHAR}
      </if>
      <if test="userId != null">
        AND user_id=#{userId,jdbcType=VARCHAR}
      </if>
      <if test="recordType != null">
        AND record_type=#{recordType,jdbcType=VARCHAR}
      </if>
    </trim>
  </select>

</mapper>