<?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.project.business.mapper.quotation.TqAdditionalFeesMapper">

    <resultMap type="TqAdditionalFees" id="TqAdditionalFeesResult">
        <result property="id" column="id"/>
        <result property="quotationId" column="quotation_id"/>
        <result property="feesType" column="fees_type"/>
        <result property="currencyId" column="currency_id"/>
        <result property="exchangeRate" column="exchange_rate"/>
        <result property="additionalFees" column="additional_fees"/>
        <result property="delFlag" column="del_flag"/>
        <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="remark" column="remark"/>
    </resultMap>

    <sql id="selectTqAdditionalFeesVo">
        select id,
               quotation_id,
               fees_type,
               currency_id,
               exchange_rate,
               additional_fees,
               del_flag,
               create_time,
               create_by,
               update_time,
               update_by,
               remark
        from tq_additional_fees
    </sql>

    <select id="selectTqAdditionalFeesList" parameterType="TqAdditionalFees" resultMap="TqAdditionalFeesResult">
        <include refid="selectTqAdditionalFeesVo"/>
        <where>
            <if test="quotationId != null ">and quotation_id = #{quotationId}</if>
            <if test="feesType != null  and feesType != ''">and fees_type = #{feesType}</if>
            <if test="currencyId != null ">and currency_id = #{currencyId}</if>
            <if test="exchangeRate != null ">and exchange_rate = #{exchangeRate}</if>
            <if test="additionalFees != null ">and additional_fees = #{additionalFees}</if>
        </where>
    </select>

    <select id="selectTqAdditionalFeesById" parameterType="Long" resultMap="TqAdditionalFeesResult">
        <include refid="selectTqAdditionalFeesVo"/>
        where id = #{id}
    </select>

    <insert id="insertTqAdditionalFees" parameterType="TqAdditionalFees" useGeneratedKeys="true" keyProperty="id">
        insert into tq_additional_fees
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="quotationId != null">quotation_id,</if>
            <if test="feesType != null">fees_type,</if>
            <if test="currencyId != null">currency_id,</if>
            <if test="exchangeRate != null">exchange_rate,</if>
            <if test="additionalFees != null">additional_fees,</if>
            <if test="delFlag != null">del_flag,</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="remark != null">remark,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="quotationId != null">#{quotationId},</if>
            <if test="feesType != null">#{feesType},</if>
            <if test="currencyId != null">#{currencyId},</if>
            <if test="exchangeRate != null">#{exchangeRate},</if>
            <if test="additionalFees != null">#{additionalFees},</if>
            <if test="delFlag != null">#{delFlag},</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="remark != null">#{remark},</if>
        </trim>
    </insert>

    <update id="updateTqAdditionalFees" parameterType="TqAdditionalFees">
        update tq_additional_fees
        <trim prefix="SET" suffixOverrides=",">
            <if test="quotationId != null">quotation_id = #{quotationId},</if>
            <if test="feesType != null">fees_type = #{feesType},</if>
            <if test="currencyId != null">currency_id = #{currencyId},</if>
            <if test="exchangeRate != null">exchange_rate = #{exchangeRate},</if>
            <if test="additionalFees != null">additional_fees = #{additionalFees},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</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="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTqAdditionalFeesById" parameterType="Long">
        delete
        from tq_additional_fees
        where id = #{id}
    </delete>

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