<?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.CreditMapper">
  <resultMap id="BaseResultMap" type="com.usoft.fin.grpc.dal.entity.Credit">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="code" jdbcType="VARCHAR" property="code" />
    <result column="enuu" jdbcType="INTEGER" property="enuu" />
    <result column="product_code" jdbcType="VARCHAR" property="productCode" />
    <result column="credit_apply_code" jdbcType="VARCHAR" property="creditApplyCode" />
    <result column="rate" jdbcType="DECIMAL" property="rate" />
    <result column="reply_amount" jdbcType="DECIMAL" property="replyAmount" />
    <result column="used_amount" jdbcType="DECIMAL" property="usedAmount" />
    <result column="usable_amount" jdbcType="DECIMAL" property="usableAmount" />
    <result column="start_date" jdbcType="VARCHAR" property="startDate" />
    <result column="end_date" jdbcType="VARCHAR" property="endDate" />
  </resultMap>
  <sql id="Base_Column_List">
    id, code, enuu, product_code, credit_apply_code, rate, reply_amount, used_amount, 
    usable_amount, start_date, end_date
  </sql>
  <sql id="Table_Base_Column_List">
    t_credit.id, t_credit.code, t_credit.enuu, t_credit.product_code, t_credit.credit_apply_code, 
    t_credit.rate, t_credit.reply_amount, t_credit.used_amount, t_credit.usable_amount, 
    t_credit.start_date, t_credit.end_date
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from t_credit
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from t_credit
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.usoft.fin.grpc.dal.entity.Credit">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into t_credit (code, enuu, product_code, 
      credit_apply_code, rate, reply_amount, 
      used_amount, usable_amount, start_date, 
      end_date)
    values (#{code,jdbcType=VARCHAR}, #{enuu,jdbcType=INTEGER}, #{productCode,jdbcType=VARCHAR}, 
      #{creditApplyCode,jdbcType=VARCHAR}, #{rate,jdbcType=DECIMAL}, #{replyAmount,jdbcType=DECIMAL}, 
      #{usedAmount,jdbcType=DECIMAL}, #{usableAmount,jdbcType=DECIMAL}, #{startDate,jdbcType=VARCHAR}, 
      #{endDate,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.usoft.fin.grpc.dal.entity.Credit">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into t_credit
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="code != null">
        code,
      </if>
      <if test="enuu != null">
        enuu,
      </if>
      <if test="productCode != null">
        product_code,
      </if>
      <if test="creditApplyCode != null">
        credit_apply_code,
      </if>
      <if test="rate != null">
        rate,
      </if>
      <if test="replyAmount != null">
        reply_amount,
      </if>
      <if test="usedAmount != null">
        used_amount,
      </if>
      <if test="usableAmount != null">
        usable_amount,
      </if>
      <if test="startDate != null">
        start_date,
      </if>
      <if test="endDate != null">
        end_date,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="code != null">
        #{code,jdbcType=VARCHAR},
      </if>
      <if test="enuu != null">
        #{enuu,jdbcType=INTEGER},
      </if>
      <if test="productCode != null">
        #{productCode,jdbcType=VARCHAR},
      </if>
      <if test="creditApplyCode != null">
        #{creditApplyCode,jdbcType=VARCHAR},
      </if>
      <if test="rate != null">
        #{rate,jdbcType=DECIMAL},
      </if>
      <if test="replyAmount != null">
        #{replyAmount,jdbcType=DECIMAL},
      </if>
      <if test="usedAmount != null">
        #{usedAmount,jdbcType=DECIMAL},
      </if>
      <if test="usableAmount != null">
        #{usableAmount,jdbcType=DECIMAL},
      </if>
      <if test="startDate != null">
        #{startDate,jdbcType=VARCHAR},
      </if>
      <if test="endDate != null">
        #{endDate,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.usoft.fin.grpc.dal.entity.Credit">
    update t_credit
    <set>
      <if test="code != null">
        code = #{code,jdbcType=VARCHAR},
      </if>
      <if test="enuu != null">
        enuu = #{enuu,jdbcType=INTEGER},
      </if>
      <if test="productCode != null">
        product_code = #{productCode,jdbcType=VARCHAR},
      </if>
      <if test="creditApplyCode != null">
        credit_apply_code = #{creditApplyCode,jdbcType=VARCHAR},
      </if>
      <if test="rate != null">
        rate = #{rate,jdbcType=DECIMAL},
      </if>
      <if test="replyAmount != null">
        reply_amount = #{replyAmount,jdbcType=DECIMAL},
      </if>
      <if test="usedAmount != null">
        used_amount = #{usedAmount,jdbcType=DECIMAL},
      </if>
      <if test="usableAmount != null">
        usable_amount = #{usableAmount,jdbcType=DECIMAL},
      </if>
      <if test="startDate != null">
        start_date = #{startDate,jdbcType=VARCHAR},
      </if>
      <if test="endDate != null">
        end_date = #{endDate,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.usoft.fin.grpc.dal.entity.Credit">
    update t_credit
    set code = #{code,jdbcType=VARCHAR},
      enuu = #{enuu,jdbcType=INTEGER},
      product_code = #{productCode,jdbcType=VARCHAR},
      credit_apply_code = #{creditApplyCode,jdbcType=VARCHAR},
      rate = #{rate,jdbcType=DECIMAL},
      reply_amount = #{replyAmount,jdbcType=DECIMAL},
      used_amount = #{usedAmount,jdbcType=DECIMAL},
      usable_amount = #{usableAmount,jdbcType=DECIMAL},
      start_date = #{startDate,jdbcType=VARCHAR},
      end_date = #{endDate,jdbcType=VARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>
</mapper>