<?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.TransactionDetailsMapper">
    
    <resultMap type="TransactionDetails" id="TransactionDetailsResult">
        <result property="id"    column="id"    />
        <result property="createTime"    column="create_time"    />
        <result property="detailsName"    column="details_name"    />
        <result property="detailsPrice"    column="details_price"    />
        <result property="transactionType"    column="transaction_type"    />
    </resultMap>

    <sql id="selectTransactionDetailsVo">
        select id, create_time, details_name, details_price, transaction_type from transaction_details
    </sql>

    <select id="selectTransactionDetailsList" parameterType="TransactionDetails" resultMap="TransactionDetailsResult">
        <include refid="selectTransactionDetailsVo"/>
        <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>
        </where>
    </select>
    
    <select id="selectTransactionDetailsById" parameterType="Long" resultMap="TransactionDetailsResult">
        <include refid="selectTransactionDetailsVo"/>
        where id = #{id}
    </select>
    <select id="getTransactionDetailsList" resultType="com.ruoyi.model.domain.TransactionDetails">
        <include refid="selectTransactionDetailsVo"/>
    </select>

    <insert id="insertTransactionDetails" parameterType="TransactionDetails">
        insert into transaction_details
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="createTime != null">create_time,</if>
            <if test="detailsName != null">details_name,</if>
            <if test="detailsPrice != null">details_price,</if>
            <if test="transactionType != null">transaction_type,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="detailsName != null">#{detailsName},</if>
            <if test="detailsPrice != null">#{detailsPrice},</if>
            <if test="transactionType != null">#{transactionType},</if>
         </trim>
    </insert>

    <update id="updateTransactionDetails" parameterType="TransactionDetails">
        update transaction_details
        <trim prefix="SET" suffixOverrides=",">
            <if test="createTime != null">create_time = #{createTime},</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>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTransactionDetailsById" parameterType="Long">
        delete from transaction_details where id = #{id}
    </delete>

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