<?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.RepayPlanMapper">
  <resultMap id="BaseResultMap" type="com.usoft.fin.grpc.dal.entity.RepayPlan">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="code" jdbcType="VARCHAR" property="code" />
    <result column="repay_code" jdbcType="VARCHAR" property="repayCode" />
    <result column="repay_date" jdbcType="VARCHAR" property="repayDate" />
    <result column="should_repay_interest" jdbcType="DECIMAL" property="shouldRepayInterest" />
    <result column="should_repay_principal" jdbcType="DECIMAL" property="shouldRepayPrincipal" />
    <result column="should_repay_total" jdbcType="DECIMAL" property="shouldRepayTotal" />
    <result column="periods_number" jdbcType="SMALLINT" property="periodsNumber" />
    <result column="status" jdbcType="SMALLINT" property="status" />
  </resultMap>
  <sql id="Base_Column_List">
    id, code, repay_code, repay_date, should_repay_interest, should_repay_principal, 
    should_repay_total, periods_number, status
  </sql>
  <sql id="Table_Base_Column_List">
    t_repay_plan.id, t_repay_plan.code, t_repay_plan.repay_code, t_repay_plan.repay_date, 
    t_repay_plan.should_repay_interest, t_repay_plan.should_repay_principal, t_repay_plan.should_repay_total, 
    t_repay_plan.periods_number, t_repay_plan.status
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from t_repay_plan
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from t_repay_plan
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.usoft.fin.grpc.dal.entity.RepayPlan">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into t_repay_plan (code, repay_code, repay_date, 
      should_repay_interest, should_repay_principal, 
      should_repay_total, periods_number, status
      )
    values (#{code,jdbcType=VARCHAR}, #{repayCode,jdbcType=VARCHAR}, #{repayDate,jdbcType=VARCHAR}, 
      #{shouldRepayInterest,jdbcType=DECIMAL}, #{shouldRepayPrincipal,jdbcType=DECIMAL}, 
      #{shouldRepayTotal,jdbcType=DECIMAL}, #{periodsNumber,jdbcType=SMALLINT}, #{status,jdbcType=SMALLINT}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.usoft.fin.grpc.dal.entity.RepayPlan">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into t_repay_plan
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="code != null">
        code,
      </if>
      <if test="repayCode != null">
        repay_code,
      </if>
      <if test="repayDate != null">
        repay_date,
      </if>
      <if test="shouldRepayInterest != null">
        should_repay_interest,
      </if>
      <if test="shouldRepayPrincipal != null">
        should_repay_principal,
      </if>
      <if test="shouldRepayTotal != null">
        should_repay_total,
      </if>
      <if test="periodsNumber != null">
        periods_number,
      </if>
      <if test="status != null">
        status,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="code != null">
        #{code,jdbcType=VARCHAR},
      </if>
      <if test="repayCode != null">
        #{repayCode,jdbcType=VARCHAR},
      </if>
      <if test="repayDate != null">
        #{repayDate,jdbcType=VARCHAR},
      </if>
      <if test="shouldRepayInterest != null">
        #{shouldRepayInterest,jdbcType=DECIMAL},
      </if>
      <if test="shouldRepayPrincipal != null">
        #{shouldRepayPrincipal,jdbcType=DECIMAL},
      </if>
      <if test="shouldRepayTotal != null">
        #{shouldRepayTotal,jdbcType=DECIMAL},
      </if>
      <if test="periodsNumber != null">
        #{periodsNumber,jdbcType=SMALLINT},
      </if>
      <if test="status != null">
        #{status,jdbcType=SMALLINT},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.usoft.fin.grpc.dal.entity.RepayPlan">
    update t_repay_plan
    <set>
      <if test="code != null">
        code = #{code,jdbcType=VARCHAR},
      </if>
      <if test="repayCode != null">
        repay_code = #{repayCode,jdbcType=VARCHAR},
      </if>
      <if test="repayDate != null">
        repay_date = #{repayDate,jdbcType=VARCHAR},
      </if>
      <if test="shouldRepayInterest != null">
        should_repay_interest = #{shouldRepayInterest,jdbcType=DECIMAL},
      </if>
      <if test="shouldRepayPrincipal != null">
        should_repay_principal = #{shouldRepayPrincipal,jdbcType=DECIMAL},
      </if>
      <if test="shouldRepayTotal != null">
        should_repay_total = #{shouldRepayTotal,jdbcType=DECIMAL},
      </if>
      <if test="periodsNumber != null">
        periods_number = #{periodsNumber,jdbcType=SMALLINT},
      </if>
      <if test="status != null">
        status = #{status,jdbcType=SMALLINT},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.usoft.fin.grpc.dal.entity.RepayPlan">
    update t_repay_plan
    set code = #{code,jdbcType=VARCHAR},
      repay_code = #{repayCode,jdbcType=VARCHAR},
      repay_date = #{repayDate,jdbcType=VARCHAR},
      should_repay_interest = #{shouldRepayInterest,jdbcType=DECIMAL},
      should_repay_principal = #{shouldRepayPrincipal,jdbcType=DECIMAL},
      should_repay_total = #{shouldRepayTotal,jdbcType=DECIMAL},
      periods_number = #{periodsNumber,jdbcType=SMALLINT},
      status = #{status,jdbcType=SMALLINT}
    where id = #{id,jdbcType=INTEGER}
  </update>
</mapper>