<?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.RepayDetailMapper">
    <insert id="insertAllSelective" parameterType="collection">
        <foreach collection="collection" item="item" index="index" separator=";">
            insert into t_repay_detail
            <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="item.code != null">
                    code,
                </if>
                <if test="item.repayCode != null">
                    repay_code,
                </if>
                <if test="item.repayDate != null">
                    repay_date,
                </if>
                <if test="item.actualRepayInterest != null">
                    actual_repay_interest,
                </if>
                <if test="item.actualRepayPrincipal != null">
                    actual_repay_principal,
                </if>
                <if test="item.shouldRepayTotal != null">
                    should_repay_total,
                </if>
                <if test="item.overRepayPrincipal != null">
                    over_repay_principal,
                </if>
                <if test="item.overRepayInterest != null">
                    over_repay_interest,
                </if>
                <if test="item.overDateCount != null">
                    over_date_count,
                </if>
            </trim>
            values
            <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="item.code != null">
                    #{item.code},
                </if>
                <if test="item.repayCode != null">
                    #{item.repayCode},
                </if>
                <if test="item.repayDate != null">
                    #{item.repayDate},
                </if>
                <if test="item.actualRepayInterest != null">
                    #{item.actualRepayInterest},
                </if>
                <if test="item.actualRepayPrincipal != null">
                    #{item.actualRepayPrincipal},
                </if>
                <if test="item.shouldRepayTotal != null">
                    #{item.shouldRepayTotal},
                </if>
                <if test="item.overRepayPrincipal != null">
                    #{item.overRepayPrincipal},
                </if>
                <if test="item.overRepayInterest != null">
                    #{item.overRepayInterest},
                </if>
                <if test="item.overDateCount != null">
                    #{item.overDateCount},
                </if>
            </trim>
        </foreach>
    </insert>

    <delete id="deleteAllByRepayCode">
        delete from t_repay_detail where 1=0
        <trim>
            <if test="repayCode != null">
                or repay_code = #{repayCode}
            </if>
        </trim>
    </delete>

    <select id="findByRepayCode" parameterType="string" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from t_repay_detail where repay_code = #{repayCode}
    </select>
</mapper>