<?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.AppDepositMapper">
    
    <resultMap type="AppDeposit" id="AppDepositResult">
        <result property="id"    column="id"    />
        <result property="detailsName"    column="details_name"    />
        <result property="detailsPrice"    column="details_price"    />
        <result property="transactionType"    column="transaction_type"    />
        <result property="usersId"    column="users_id"    />
        <result property="remark"    column="remark"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="delFlag"    column="del_flag"    />
    </resultMap>

    <sql id="selectAppDepositVo">
        select id, details_name, details_price, transaction_type, users_id, remark, create_time, create_by, update_time, update_by, del_flag from app_deposit
    </sql>

    <select id="selectAppDepositList" parameterType="AppDeposit" resultMap="AppDepositResult">
        <include refid="selectAppDepositVo"/>
        <where>  
            <if test="detailsName != null  and detailsName != ''"> and details_name like concat('%', #{detailsName}, '%')</if>
            <if test="detailsPrice != null "> and details_price = #{detailsPrice}</if>
            <if test="transactionType != null "> and transaction_type = #{transactionType}</if>
            <if test="usersId != null "> and users_id = #{usersId}</if>
        </where>
    </select>
    
    <select id="selectAppDepositById" parameterType="Long" resultMap="AppDepositResult">
        <include refid="selectAppDepositVo"/>
        where id = #{id}
    </select>
    <select id="getAppDepositListByUserId" resultType="com.ruoyi.model.domain.AppDeposit">
        <include refid="selectAppDepositVo"/> where users_id = #{users_id} and del_flag = 0;
    </select>

    <insert id="insertAppDeposit" parameterType="AppDeposit">
        insert into app_deposit
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="detailsName != null">details_name,</if>
            <if test="detailsPrice != null">details_price,</if>
            <if test="transactionType != null">transaction_type,</if>
            <if test="usersId != null">users_id,</if>
            <if test="remark != null">remark,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="delFlag != null">del_flag,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="detailsName != null">#{detailsName},</if>
            <if test="detailsPrice != null">#{detailsPrice},</if>
            <if test="transactionType != null">#{transactionType},</if>
            <if test="usersId != null">#{usersId},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="delFlag != null">#{delFlag},</if>
         </trim>
    </insert>

    <update id="updateAppDeposit" parameterType="AppDeposit">
        update app_deposit
        <trim prefix="SET" suffixOverrides=",">
            <if test="detailsName != null">details_name = #{detailsName},</if>
            <if test="detailsPrice != null">details_price = #{detailsPrice},</if>
            <if test="transactionType != null">transaction_type = #{transactionType},</if>
            <if test="usersId != null">users_id = #{usersId},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAppDepositById" parameterType="Long">
        delete from app_deposit where id = #{id}
    </delete>

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