<?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.usoft.fin.grpc.dal.mapper.RepayMapper">
  <resultMap id="BaseResultMap" type="com.usoft.fin.grpc.dal.entity.Repay">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="code" jdbcType="VARCHAR" property="code" />
    <result column="draw_code" jdbcType="VARCHAR" property="drawCode" />
    <result column="repay_plan_code" jdbcType="VARCHAR" property="repayPlanCode" />
    <result column="product_code" jdbcType="VARCHAR" property="productCode" />
    <result column="enuu" jdbcType="INTEGER" property="enuu" />
    <result column="start_date" jdbcType="VARCHAR" property="startDate" />
    <result column="end_date" jdbcType="VARCHAR" property="endDate" />
    <result column="draw_amount" jdbcType="DECIMAL" property="drawAmount" />
    <result column="draw_month_rate" jdbcType="DECIMAL" property="drawMonthRate" />
    <result column="current_repay_moment" jdbcType="DECIMAL" property="currentRepayMoment" />
    <result column="current_repay_time" jdbcType="VARCHAR" property="currentRepayTime" />
  </resultMap>
  <sql id="Base_Column_List">
    id, code, draw_code, repay_plan_code, product_code, enuu, start_date, end_date, draw_amount, 
    draw_month_rate, current_repay_moment, current_repay_time
  </sql>
  <sql id="Table_Base_Column_List">
    t_repay.id, t_repay.code, t_repay.draw_code, t_repay.repay_plan_code, t_repay.product_code, 
    t_repay.enuu, t_repay.start_date, t_repay.end_date, t_repay.draw_amount, t_repay.draw_month_rate, 
    t_repay.current_repay_moment, t_repay.current_repay_time
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from t_repay
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from t_repay
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.usoft.fin.grpc.dal.entity.Repay">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into t_repay (code, draw_code, repay_plan_code, 
      product_code, enuu, start_date, 
      end_date, draw_amount, draw_month_rate, 
      current_repay_moment, current_repay_time)
    values (#{code,jdbcType=VARCHAR}, #{drawCode,jdbcType=VARCHAR}, #{repayPlanCode,jdbcType=VARCHAR}, 
      #{productCode,jdbcType=VARCHAR}, #{enuu,jdbcType=INTEGER}, #{startDate,jdbcType=VARCHAR}, 
      #{endDate,jdbcType=VARCHAR}, #{drawAmount,jdbcType=DECIMAL}, #{drawMonthRate,jdbcType=DECIMAL}, 
      #{currentRepayMoment,jdbcType=DECIMAL}, #{currentRepayTime,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.usoft.fin.grpc.dal.entity.Repay">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into t_repay
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="code != null">
        code,
      </if>
      <if test="drawCode != null">
        draw_code,
      </if>
      <if test="repayPlanCode != null">
        repay_plan_code,
      </if>
      <if test="productCode != null">
        product_code,
      </if>
      <if test="enuu != null">
        enuu,
      </if>
      <if test="startDate != null">
        start_date,
      </if>
      <if test="endDate != null">
        end_date,
      </if>
      <if test="drawAmount != null">
        draw_amount,
      </if>
      <if test="drawMonthRate != null">
        draw_month_rate,
      </if>
      <if test="currentRepayMoment != null">
        current_repay_moment,
      </if>
      <if test="currentRepayTime != null">
        current_repay_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="code != null">
        #{code,jdbcType=VARCHAR},
      </if>
      <if test="drawCode != null">
        #{drawCode,jdbcType=VARCHAR},
      </if>
      <if test="repayPlanCode != null">
        #{repayPlanCode,jdbcType=VARCHAR},
      </if>
      <if test="productCode != null">
        #{productCode,jdbcType=VARCHAR},
      </if>
      <if test="enuu != null">
        #{enuu,jdbcType=INTEGER},
      </if>
      <if test="startDate != null">
        #{startDate,jdbcType=VARCHAR},
      </if>
      <if test="endDate != null">
        #{endDate,jdbcType=VARCHAR},
      </if>
      <if test="drawAmount != null">
        #{drawAmount,jdbcType=DECIMAL},
      </if>
      <if test="drawMonthRate != null">
        #{drawMonthRate,jdbcType=DECIMAL},
      </if>
      <if test="currentRepayMoment != null">
        #{currentRepayMoment,jdbcType=DECIMAL},
      </if>
      <if test="currentRepayTime != null">
        #{currentRepayTime,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.usoft.fin.grpc.dal.entity.Repay">
    update t_repay
    <set>
      <if test="code != null">
        code = #{code,jdbcType=VARCHAR},
      </if>
      <if test="drawCode != null">
        draw_code = #{drawCode,jdbcType=VARCHAR},
      </if>
      <if test="repayPlanCode != null">
        repay_plan_code = #{repayPlanCode,jdbcType=VARCHAR},
      </if>
      <if test="productCode != null">
        product_code = #{productCode,jdbcType=VARCHAR},
      </if>
      <if test="enuu != null">
        enuu = #{enuu,jdbcType=INTEGER},
      </if>
      <if test="startDate != null">
        start_date = #{startDate,jdbcType=VARCHAR},
      </if>
      <if test="endDate != null">
        end_date = #{endDate,jdbcType=VARCHAR},
      </if>
      <if test="drawAmount != null">
        draw_amount = #{drawAmount,jdbcType=DECIMAL},
      </if>
      <if test="drawMonthRate != null">
        draw_month_rate = #{drawMonthRate,jdbcType=DECIMAL},
      </if>
      <if test="currentRepayMoment != null">
        current_repay_moment = #{currentRepayMoment,jdbcType=DECIMAL},
      </if>
      <if test="currentRepayTime != null">
        current_repay_time = #{currentRepayTime,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.usoft.fin.grpc.dal.entity.Repay">
    update t_repay
    set code = #{code,jdbcType=VARCHAR},
      draw_code = #{drawCode,jdbcType=VARCHAR},
      repay_plan_code = #{repayPlanCode,jdbcType=VARCHAR},
      product_code = #{productCode,jdbcType=VARCHAR},
      enuu = #{enuu,jdbcType=INTEGER},
      start_date = #{startDate,jdbcType=VARCHAR},
      end_date = #{endDate,jdbcType=VARCHAR},
      draw_amount = #{drawAmount,jdbcType=DECIMAL},
      draw_month_rate = #{drawMonthRate,jdbcType=DECIMAL},
      current_repay_moment = #{currentRepayMoment,jdbcType=DECIMAL},
      current_repay_time = #{currentRepayTime,jdbcType=VARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>
</mapper>