<?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.leromro.core.mapper.VolunteerAccountChangeMapper">
    
    <resultMap type="VolunteerAccountChange" id="VolunteerAccountChangeResult">
        <result property="volunteerAccountChangeId"    column="volunteer_account_change_id"    />
        <result property="changeType"    column="change_type"    />
        <result property="sourceType"    column="source_type"    />
        <result property="changeMoney"    column="change_money"    />
        <result property="beforeBalance"    column="before_balance"    />
        <result property="afterBalance"    column="after_balance"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectVolunteerAccountChangeVo">
        select volunteer_account_change_id, change_type, source_type, change_money, before_balance, after_balance, create_by, create_time, update_by, update_time, remark from l_volunteer_account_change
    </sql>

    <select id="selectVolunteerAccountChangeList" parameterType="VolunteerAccountChange" resultMap="VolunteerAccountChangeResult">
        <include refid="selectVolunteerAccountChangeVo"/>
        <where>  
            <if test="changeType != null "> and change_type = #{changeType}</if>
            <if test="sourceType != null "> and source_type = #{sourceType}</if>
            <if test="changeMoney != null "> and change_money = #{changeMoney}</if>
            <if test="beforeBalance != null "> and before_balance = #{beforeBalance}</if>
            <if test="afterBalance != null "> and after_balance = #{afterBalance}</if>
        </where>
    </select>
    
    <select id="selectVolunteerAccountChangeByVolunteerAccountChangeId" parameterType="Long" resultMap="VolunteerAccountChangeResult">
        <include refid="selectVolunteerAccountChangeVo"/>
        where volunteer_account_change_id = #{volunteerAccountChangeId}
    </select>

    <insert id="insertVolunteerAccountChange" parameterType="VolunteerAccountChange" useGeneratedKeys="true" keyProperty="volunteerAccountChangeId">
        insert into l_volunteer_account_change
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="changeType != null">change_type,</if>
            <if test="sourceType != null">source_type,</if>
            <if test="changeMoney != null">change_money,</if>
            <if test="beforeBalance != null">before_balance,</if>
            <if test="afterBalance != null">after_balance,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="changeType != null">#{changeType},</if>
            <if test="sourceType != null">#{sourceType},</if>
            <if test="changeMoney != null">#{changeMoney},</if>
            <if test="beforeBalance != null">#{beforeBalance},</if>
            <if test="afterBalance != null">#{afterBalance},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateVolunteerAccountChange" parameterType="VolunteerAccountChange">
        update l_volunteer_account_change
        <trim prefix="SET" suffixOverrides=",">
            <if test="changeType != null">change_type = #{changeType},</if>
            <if test="sourceType != null">source_type = #{sourceType},</if>
            <if test="changeMoney != null">change_money = #{changeMoney},</if>
            <if test="beforeBalance != null">before_balance = #{beforeBalance},</if>
            <if test="afterBalance != null">after_balance = #{afterBalance},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where volunteer_account_change_id = #{volunteerAccountChangeId}
    </update>

    <delete id="deleteVolunteerAccountChangeByVolunteerAccountChangeId" parameterType="Long">
        delete from l_volunteer_account_change where volunteer_account_change_id = #{volunteerAccountChangeId}
    </delete>

    <delete id="deleteVolunteerAccountChangeByVolunteerAccountChangeIds" parameterType="String">
        delete from l_volunteer_account_change where volunteer_account_change_id in 
        <foreach item="volunteerAccountChangeId" collection="array" open="(" separator="," close=")">
            #{volunteerAccountChangeId}
        </foreach>
    </delete>
</mapper>