<?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.AppTransactionDetailsMapper">
    
    <resultMap type="AppTransactionDetails" id="AppTransactionDetailsResult">
        <result property="id"    column="id"    />
        <result property="wid"    column="wid"    />
        <result property="detailsName"    column="details_name"    />
        <result property="detailsPrice"    column="details_price"    />
        <result property="transactionType"    column="transaction_type"    />
        <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="selectAppTransactionDetailsVo">
        select id, wid, details_name, details_price, transaction_type, remark, create_time, create_by, update_time, update_by, del_flag from app_transaction_details
    </sql>

    <select id="selectAppTransactionDetailsList" parameterType="AppTransactionDetails" resultMap="AppTransactionDetailsResult">
        <include refid="selectAppTransactionDetailsVo"/>
        <where>  
            <if test="wid != null "> and wid = #{wid}</if>
            <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>
        </where>
    </select>
    
    <select id="selectAppTransactionDetailsById" parameterType="Long" resultMap="AppTransactionDetailsResult">
        <include refid="selectAppTransactionDetailsVo"/>
        where id = #{id}
    </select>
    <select id="getAppTransactionDetailsByWid" resultType="com.ruoyi.model.domain.AppTransactionDetails">
        <include refid="selectAppTransactionDetailsVo"/>
        where wid = #{wid} and del_flag = 0;
    </select>

    <insert id="insertAppTransactionDetails" parameterType="AppTransactionDetails">
        insert into app_transaction_details
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="wid != null">wid,</if>
            <if test="detailsName != null">details_name,</if>
            <if test="detailsPrice != null">details_price,</if>
            <if test="transactionType != null">transaction_type,</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="wid != null">#{wid},</if>
            <if test="detailsName != null">#{detailsName},</if>
            <if test="detailsPrice != null">#{detailsPrice},</if>
            <if test="transactionType != null">#{transactionType},</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="updateAppTransactionDetails" parameterType="AppTransactionDetails">
        update app_transaction_details
        <trim prefix="SET" suffixOverrides=",">
            <if test="wid != null">wid = #{wid},</if>
            <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="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="deleteAppTransactionDetailsById" parameterType="Long">
        delete from app_transaction_details where id = #{id}
    </delete>

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