<?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.model.mapper.AppletAmountLogMapper">
    
    <resultMap type="AppletAmountLog" id="AppletAmountLogResult">
        <result property="id" column="id"/>
        <result property="title" column="title"/>
        <result property="amount" column="amount"/>
        <result property="type" column="type"/>
        <result property="delFlag" column="del_flag"/>
        <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="userId" column="user_id"/>
        <result property="state" column="state"/>
        <result property="moneyType" column="money_type"/>
        <result property="nameValue" column="name_value"/>
    </resultMap>

    <sql id="selectAppletAmountLogVo">
        select id, title, amount, type, del_flag, create_by, create_time, update_by, update_time, user_id, state , money_type, name_value from applet_amount_log
    </sql>

    <select id="selectAppletAmountLogList" parameterType="AppletAmountLog" resultMap="AppletAmountLogResult">
        <include refid="selectAppletAmountLogVo"/>
        <where>
            <if test="title != null  and title != ''"> and title = #{title}</if>
            <if test="amount != null "> and amount = #{amount}</if>
            <if test="type != null "> and type = #{type}</if>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="state != null "> and state = #{state}</if>
            <if test="moneyType != null "> and money_type = #{moneyType}</if>
            <if test="nameValue != null  and nameValue != ''"> and name_value like concat('%', #{nameValue}, '%')</if>
        </where>
        order by create_time desc
    </select>
    
    <select id="selectAppletAmountLogById" parameterType="AppletAmountLog" resultMap="AppletAmountLogResult">
        <include refid="selectAppletAmountLogVo"/>
        where id = #{id}
    </select>

    <insert id="insertAppletAmountLog" parameterType="AppletAmountLog" useGeneratedKeys="true" keyProperty="id">
        insert into applet_amount_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="title != null and title != ''">title,</if>
            <if test="amount != null">amount,</if>
            <if test="type != null">type,</if>
            <if test="delFlag != null">del_flag,</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="userId != null">user_id,</if>
            <if test="state != null">state,</if>
            <if test="moneyType != null">money_type,</if>
            <if test="nameValue != null">name_value,</if>

        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="title != null and title != ''">#{title},</if>
            <if test="amount != null">#{amount},</if>
            <if test="type != null">#{type},</if>
            <if test="delFlag != null">#{delFlag},</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="userId != null">#{userId},</if>
            <if test="state != null">#{state},</if>
            <if test="moneyType != null">#{moneyType},</if>
            <if test="nameValue != null">#{nameValue},</if>
        </trim>
    </insert>

    <update id="updateAppletAmountLog" parameterType="AppletAmountLog">
        update applet_amount_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="title != null and title != ''">title = #{title},</if>
            <if test="amount != null">amount = #{amount},</if>
            <if test="type != null">type = #{type},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</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="userId != null">user_id = #{userId},</if>
            <if test="state != null">state = #{state},</if>
            <if test="moneyType != null">money_type = #{moneyType},</if>
            <if test="nameValue != null">name_value = #{nameValue},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAppletAmountLogById" parameterType="Long">
        delete from applet_amount_log where id = #{id}
    </delete>

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