<?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">
<mapper namespace="com.goafanti.common.dao.PatentPaymentDetailsMapper">
  <resultMap id="BaseResultMap" type="com.goafanti.common.model.PatentPaymentDetails">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Aug 06 15:00:19 CST 2021.
    -->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="pid" jdbcType="INTEGER" property="pid" />
    <result column="years" jdbcType="INTEGER" property="years" />
    <result column="patent_amount" jdbcType="DECIMAL" property="patentAmount" />
    <result column="end_date" jdbcType="DATE" property="endDate" />
    <result column="status" jdbcType="INTEGER" property="status" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Aug 06 15:00:19 CST 2021.
    -->
    id, pid, `years`, patent_amount, end_date, `status`, create_time
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Aug 06 15:00:19 CST 2021.
    -->
    select 
    <include refid="Base_Column_List" />
    from patent_payment_details
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Aug 06 15:00:19 CST 2021.
    -->
    delete from patent_payment_details
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.goafanti.common.model.PatentPaymentDetails">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Aug 06 15:00:19 CST 2021.
    -->
    insert into patent_payment_details (id, pid, `years`, 
      patent_amount, end_date, `status`, 
      create_time)
    values (#{id,jdbcType=INTEGER}, #{pid,jdbcType=INTEGER}, #{years,jdbcType=INTEGER}, 
      #{patentAmount,jdbcType=DECIMAL}, #{endDate,jdbcType=DATE}, #{status,jdbcType=INTEGER}, 
      #{createTime,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" parameterType="com.goafanti.common.model.PatentPaymentDetails">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Aug 06 15:00:19 CST 2021.
    -->
    insert into patent_payment_details
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="pid != null">
        pid,
      </if>
      <if test="years != null">
        `years`,
      </if>
      <if test="patentAmount != null">
        patent_amount,
      </if>
      <if test="endDate != null">
        end_date,
      </if>
      <if test="status != null">
        `status`,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      <if test="pid != null">
        #{pid,jdbcType=INTEGER},
      </if>
      <if test="years != null">
        #{years,jdbcType=INTEGER},
      </if>
      <if test="patentAmount != null">
        #{patentAmount,jdbcType=DECIMAL},
      </if>
      <if test="endDate != null">
        #{endDate,jdbcType=DATE},
      </if>
      <if test="status != null">
        #{status,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.PatentPaymentDetails">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Aug 06 15:00:19 CST 2021.
    -->
    update patent_payment_details
    <set>
      <if test="pid != null">
        pid = #{pid,jdbcType=INTEGER},
      </if>
      <if test="years != null">
        `years` = #{years,jdbcType=INTEGER},
      </if>
      <if test="patentAmount != null">
        patent_amount = #{patentAmount,jdbcType=DECIMAL},
      </if>
      <if test="endDate != null">
        end_date = #{endDate,jdbcType=DATE},
      </if>
      <if test="status != null">
        `status` = #{status,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.PatentPaymentDetails">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Aug 06 15:00:19 CST 2021.
    -->
    update patent_payment_details
    set pid = #{pid,jdbcType=INTEGER},
      `years` = #{years,jdbcType=INTEGER},
      patent_amount = #{patentAmount,jdbcType=DECIMAL},
      end_date = #{endDate,jdbcType=DATE},
      `status` = #{status,jdbcType=INTEGER},
      create_time = #{createTime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>
  
  <insert id="insertBatch" >
    insert into patent_payment_details ( pid, `years`, 
      patent_amount, end_date, `status`
      )
    values
     <foreach collection="list" index="index" item="item" separator=",">
    ( #{item.pid,jdbcType=INTEGER}, #{item.years,jdbcType=INTEGER}, 
      #{item.patentAmount,jdbcType=DECIMAL}, #{item.endDate,jdbcType=DATE}, #{item.status,jdbcType=INTEGER}
      )
     </foreach> 
  </insert>
  
    <select id="selectByPid" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from patent_payment_details
    where pid = #{pid,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPid" >
  delete from patent_payment_details
    where pid = #{pid,jdbcType=INTEGER}
  </delete>
  
  <select id="selectByPidAndYear" resultMap="BaseResultMap">
     select 
    <include refid="Base_Column_List" />
    from patent_payment_details
    where pid = #{pid,jdbcType=INTEGER} and years= #{year,jdbcType=INTEGER}
  </select>
</mapper>