<?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.ruoyi.frequency.bondamounrecord.mapper.BondAmountRecordMapper">
    
    <resultMap type="com.ruoyi.frequency.bondamounrecord.entity.BondAmountRecord" id="BondAmountRecordResult">
        <result property="id"    column="id"    />
        <result property="createBy"    column="create_by"    />
        <result property="createdTime"    column="created_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="userType"    column="user_type"    />
        <result property="userId"    column="user_id"    />
        <result property="amount"    column="amount"    />
        <result property="currentAmount"    column="current_amount"    />
        <result property="type"    column="type"    />
    </resultMap>

    <sql id="selectBondAmountRecordVo">
        select id, create_by, created_time, update_by, update_time, del_flag, user_type, user_id, amount, current_amount, type from t_bond_amount_record
    </sql>

    <select id="selectBondAmountRecordList" parameterType="com.ruoyi.frequency.bondamounrecord.entity.BondAmountRecord" resultMap="BondAmountRecordResult">
        <include refid="selectBondAmountRecordVo"/>
        <where>  
            <if test="createdTime != null "> and created_time = #{createdTime}</if>
            <if test="userType != null "> and user_type = #{userType}</if>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="amount != null "> and amount = #{amount}</if>
            <if test="currentAmount != null "> and current_amount = #{currentAmount}</if>
            <if test="type != null "> and type = #{type}</if>
        </where>
       order by create_time desc
    </select>
    
    <select id="selectBondAmountRecordById" parameterType="Long" resultMap="BondAmountRecordResult">
        <include refid="selectBondAmountRecordVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertBondAmountRecord" parameterType="com.ruoyi.frequency.bondamounrecord.entity.BondAmountRecord">
        insert into t_bond_amount_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createdTime != null">created_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="userType != null">user_type,</if>
            <if test="userId != null">user_id,</if>
            <if test="amount != null">amount,</if>
            <if test="currentAmount != null">current_amount,</if>
            <if test="type != null">type,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createdTime != null">#{createdTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="userType != null">#{userType},</if>
            <if test="userId != null">#{userId},</if>
            <if test="amount != null">#{amount},</if>
            <if test="currentAmount != null">#{currentAmount},</if>
            <if test="type != null">#{type},</if>
         </trim>
    </insert>

    <update id="updateBondAmountRecord" parameterType="com.ruoyi.frequency.bondamounrecord.entity.BondAmountRecord">
        update t_bond_amount_record
        <trim prefix="SET" suffixOverrides=",">
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createdTime != null">created_time = #{createdTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="userType != null">user_type = #{userType},</if>
            <if test="userId != null">user_id = #{userId},</if>
            <if test="amount != null">amount = #{amount},</if>
            <if test="currentAmount != null">current_amount = #{currentAmount},</if>
            <if test="type != null">type = #{type},</if>
        </trim>
        where id = #{id}
    </update>

</mapper>