<?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 09:37:20  -->
<mapper namespace="net.northking.cctp.dw.db.dao.CaseDesignCompleteDetailsDao">
  <resultMap id="BaseResultMap" type="net.northking.cctp.dw.db.entity.CaseDesignCompleteDetails">
      <!-- 主键id -->
    <id column="id" jdbcType="VARCHAR" property="id"/>
                            <!-- 人员 -->
    <result column="receiver_name" jdbcType="VARCHAR" property="receiverName"/>
        <!-- 登陆账号 -->
    <result column="login_no" jdbcType="VARCHAR" property="loginNo"/>
        <!-- 模块 -->
    <result column="module_id" jdbcType="VARCHAR" property="moduleId"/>
        <!-- 租户id -->
    <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
        <!-- 设计中 -->
    <result column="designering" jdbcType="INTEGER" property="designering"/>
        <!-- 已完成 -->
    <result column="complete" jdbcType="INTEGER" property="complete"/>
        <!-- 0：日 1：周 2:总体 -->
    <result column="date_type" jdbcType="INTEGER" property="dateType"/>
        <!--  -->
    <result column="project_id" jdbcType="VARCHAR" property="projectId"/>
    </resultMap>

  <sql id="Base_Column_List">
    id
    ,receiver_name
    ,login_no
    ,module_id
    ,tenant_id
    ,designering
    ,complete
    ,date_type
    ,project_id
  </sql>

  <sql id="Table_Name">
    case_design_complete_details
  </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.dw.db.entity.CaseDesignCompleteDetails">
    delete 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="loginNo != null">
          AND login_no=#{loginNo,jdbcType=VARCHAR}
      </if>
      <if test="moduleId != null">
          AND module_id=#{moduleId,jdbcType=VARCHAR}
      </if>
      <if test="tenantId != null">
          AND tenant_id=#{tenantId,jdbcType=VARCHAR}
      </if>
      <if test="designering != null">
          AND designering=#{designering,jdbcType=INTEGER}
      </if>
      <if test="complete != null">
          AND complete=#{complete,jdbcType=INTEGER}
      </if>
      <if test="dateType != null">
          AND date_type=#{dateType,jdbcType=INTEGER}
      </if>
      <if test="projectId != null">
          AND project_id=#{projectId,jdbcType=VARCHAR}
      </if>
    </trim>
  </delete>

  <insert id="insert" parameterType="net.northking.cctp.dw.db.entity.CaseDesignCompleteDetails">
    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="loginNo != null">
        login_no,
      </if>
      <if test="moduleId != null">
        module_id,
      </if>
      <if test="tenantId != null">
        tenant_id,
      </if>
      <if test="designering != null">
        designering,
      </if>
      <if test="complete != null">
        complete,
      </if>
      <if test="dateType != null">
        date_type,
      </if>
      <if test="projectId != null">
        project_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="loginNo != null">
          #{loginNo, jdbcType=VARCHAR},
      </if>
      <if test="moduleId != null">
          #{moduleId, jdbcType=VARCHAR},
      </if>
      <if test="tenantId != null">
          #{tenantId, jdbcType=VARCHAR},
      </if>
      <if test="designering != null">
          #{designering, jdbcType=INTEGER},
      </if>
      <if test="complete != null">
          #{complete, jdbcType=INTEGER},
      </if>
      <if test="dateType != null">
          #{dateType, jdbcType=INTEGER},
      </if>
      <if test="projectId != null">
          #{projectId, 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,
    login_no,
    module_id,
    tenant_id,
    designering,
    complete,
    date_type,
    project_id,
    </trim>
    values
    <foreach collection="list" item="item" index="index" separator=",">
      <trim prefix="(" suffix=")" suffixOverrides=",">
    #{item.id, jdbcType=VARCHAR},
    #{item.receiverName, jdbcType=VARCHAR},
    #{item.loginNo, jdbcType=VARCHAR},
    #{item.moduleId, jdbcType=VARCHAR},
    #{item.tenantId, jdbcType=VARCHAR},
    #{item.designering, jdbcType=INTEGER},
    #{item.complete, jdbcType=INTEGER},
    #{item.dateType, jdbcType=INTEGER},
    #{item.projectId, jdbcType=VARCHAR},
      </trim>
    </foreach>
  </insert>

  <update id="updateByPrimaryKey" parameterType="net.northking.cctp.dw.db.entity.CaseDesignCompleteDetails">
    update
    <include refid="Table_Name"/>
    <set>
      <if test="receiverName != null">
        receiver_name = #{receiverName, jdbcType=VARCHAR},
      </if>
      <if test="loginNo != null">
        login_no = #{loginNo, jdbcType=VARCHAR},
      </if>
      <if test="moduleId != null">
        module_id = #{moduleId, jdbcType=VARCHAR},
      </if>
      <if test="designering != null">
        designering = #{designering, jdbcType=INTEGER},
      </if>
      <if test="complete != null">
        complete = #{complete, jdbcType=INTEGER},
      </if>
      <if test="dateType != null">
        date_type = #{dateType, jdbcType=INTEGER},
      </if>
      <if test="projectId != null">
        project_id = #{projectId, jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
    AND tenant_id = #{tenantId,jdbcType=VARCHAR}
  </update>

  <select id="query" resultMap="BaseResultMap" parameterType="net.northking.cctp.dw.db.entity.CaseDesignCompleteDetails">
    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="loginNo != null">
        AND login_no = #{loginNo,jdbcType=VARCHAR}
      </if>
      <if test="moduleId != null">
        AND module_id = #{moduleId,jdbcType=VARCHAR}
      </if>
      <if test="tenantId != null">
        AND tenant_id = #{tenantId,jdbcType=VARCHAR}
      </if>
      <if test="designering != null">
        AND designering = #{designering,jdbcType=INTEGER}
      </if>
      <if test="complete != null">
        AND complete = #{complete,jdbcType=INTEGER}
      </if>
      <if test="dateType != null">
        AND date_type = #{dateType,jdbcType=INTEGER}
      </if>
      <if test="projectId != null">
        AND project_id = #{projectId,jdbcType=VARCHAR}
      </if>
    </trim>
  </select>

  <select id="queryCount" resultType="java.lang.Long" parameterType="net.northking.cctp.dw.db.entity.CaseDesignCompleteDetails">
    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="loginNo != null">
        AND login_no=#{loginNo,jdbcType=VARCHAR}
      </if>
      <if test="moduleId != null">
        AND module_id=#{moduleId,jdbcType=VARCHAR}
      </if>
      <if test="tenantId != null">
        AND tenant_id=#{tenantId,jdbcType=VARCHAR}
      </if>
      <if test="designering != null">
        AND designering=#{designering,jdbcType=INTEGER}
      </if>
      <if test="complete != null">
        AND complete=#{complete,jdbcType=INTEGER}
      </if>
      <if test="dateType != null">
        AND date_type=#{dateType,jdbcType=INTEGER}
      </if>
      <if test="projectId != null">
        AND project_id=#{projectId,jdbcType=VARCHAR}
      </if>
    </trim>
  </select>

</mapper>