<?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.feeagreement.mapper.TWarehouseFeeAgreementTypeBusinessMapper">

    <resultMap type="TWarehouseFeeAgreementTypeBusiness" id="TWarehouseFeeAgreementTypeBusinessResult">
        <result property="fId" column="f_id"/>
        <result property="fWarehouseFeeAgreementTypeFId" column="f_warehouse_fee_agreement_type_f_id"/>
        <result property="fTFeeAgreementTypeFId" column="f_t_fee_agreement_type_f_id"/>
        <result property="fTFeeAgreementFTypeParentId" column="f_t_fee_agreement_f_type_parent_id"/>
        <result property="fFeeItem" column="f_fee_item"/>
        <result property="fComputingMethod" column="f_computing_method"/>
        <result property="fReceiptPaymentType" column="f_receipt_payment_type"/>
        <result property="fGetValue" column="f_get_value"/>
        <result property="fDelFlag" column="f_del_flag"/>
        <result property="fUpdateTime" column="f_update_time"/>
        <result property="fUpdateBy" column="f_update_by"/>
        <result property="fCreateTime" column="f_create_time"/>
        <result property="fFeeItemName" column="f_fee_item_name"/>
        <result property="fCreateBy" column="f_create_by"/>
        <result property="fRemark" column="f_remark"/>
    </resultMap>

    <sql id="selectTWarehouseFeeAgreementTypeBusinessVo">
        select b.f_id,
               b.f_warehouse_fee_agreement_type_f_id,
               b.f_t_fee_agreement_type_f_id,
               b.f_t_fee_agreement_f_type_parent_id,
               b.f_fee_item,
               b.f_computing_method,
               b.f_receipt_payment_type,
               b.f_get_value,
               b.f_del_flag,
               b.f_update_time,
               b.f_update_by,
               b.f_create_time,
               b.f_create_by,
               b.f_remark,
               f.f_name as f_fee_item_name
        from t_warehouse_fee_agreement_type_business b
                 left join t_fees f on f.f_id = b.f_fee_item
    </sql>

    <select id="selectTWarehouseFeeAgreementTypeBusinessList" parameterType="TWarehouseFeeAgreementTypeBusiness"
            resultMap="TWarehouseFeeAgreementTypeBusinessResult">
        <include refid="selectTWarehouseFeeAgreementTypeBusinessVo"/>
        <where>
            <if test="fWarehouseFeeAgreementTypeFId != null ">and b.f_warehouse_fee_agreement_type_f_id =
                #{fWarehouseFeeAgreementTypeFId}
            </if>
            <if test="fTFeeAgreementTypeFId != null ">and b.f_t_fee_agreement_type_f_id = #{fTFeeAgreementTypeFId}</if>
            <if test="fTFeeAgreementFTypeParentId != null ">and b.f_t_fee_agreement_f_type_parent_id =
                #{fTFeeAgreementFTypeParentId}
            </if>
            <if test="fFeeItem != null ">and b.f_fee_item = #{fFeeItem}</if>
            <if test="fComputingMethod != null ">and b.f_computing_method = #{fComputingMethod}</if>
            <if test="fReceiptPaymentType != null ">and b.f_receipt_payment_type = #{fReceiptPaymentType}</if>
            <if test="fGetValue != null ">and b.f_get_value = #{fGetValue}</if>
            <if test="fDelFlag != null ">and b.f_del_flag = #{fDelFlag}</if>
            <if test="fUpdateTime != null ">and b.f_update_time = #{fUpdateTime}</if>
            <if test="fUpdateBy != null ">and b.f_update_by = #{fUpdateBy}</if>
            <if test="fCreateTime != null ">and b.f_create_time = #{fCreateTime}</if>
            <if test="fCreateBy != null ">and b.f_create_by = #{fCreateBy}</if>
            <if test="fRemark != null  and fRemark != ''">and b.f_remark = #{fRemark}</if>
            and b.f_del_flag = 0
        </where>
    </select>

    <select id="selectTWarehouseFeeAgreementTypeBusinessById" parameterType="Long"
            resultMap="TWarehouseFeeAgreementTypeBusinessResult">
        <include refid="selectTWarehouseFeeAgreementTypeBusinessVo"/>
        where b.f_id = #{fId}
    </select>

    <insert id="insertTWarehouseFeeAgreementTypeBusiness" parameterType="TWarehouseFeeAgreementTypeBusiness"
            useGeneratedKeys="true" keyProperty="fId">
        insert into t_warehouse_fee_agreement_type_business
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fWarehouseFeeAgreementTypeFId != null">f_warehouse_fee_agreement_type_f_id,</if>
            <if test="fTFeeAgreementTypeFId != null">f_t_fee_agreement_type_f_id,</if>
            <if test="fTFeeAgreementFTypeParentId != null">f_t_fee_agreement_f_type_parent_id,</if>
            <if test="fFeeItem != null">f_fee_item,</if>
            <if test="fComputingMethod != null">f_computing_method,</if>
            <if test="fReceiptPaymentType != null">f_receipt_payment_type,</if>
            <if test="fGetValue != null">f_get_value,</if>
            <if test="fDelFlag != null">f_del_flag,</if>
            <if test="fUpdateTime != null">f_update_time,</if>
            <if test="fUpdateBy != null">f_update_by,</if>
            <if test="fCreateTime != null">f_create_time,</if>
            <if test="fCreateBy != null">f_create_by,</if>
            <if test="fRemark != null">f_remark,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fWarehouseFeeAgreementTypeFId != null">#{fWarehouseFeeAgreementTypeFId},</if>
            <if test="fTFeeAgreementTypeFId != null">#{fTFeeAgreementTypeFId},</if>
            <if test="fTFeeAgreementFTypeParentId != null">#{fTFeeAgreementFTypeParentId},</if>
            <if test="fFeeItem != null">#{fFeeItem},</if>
            <if test="fComputingMethod != null">#{fComputingMethod},</if>
            <if test="fReceiptPaymentType != null">#{fReceiptPaymentType},</if>
            <if test="fGetValue != null">#{fGetValue},</if>
            <if test="fDelFlag != null">#{fDelFlag},</if>
            <if test="fUpdateTime != null">#{fUpdateTime},</if>
            <if test="fUpdateBy != null">#{fUpdateBy},</if>
            <if test="fCreateTime != null">#{fCreateTime},</if>
            <if test="fCreateBy != null">#{fCreateBy},</if>
            <if test="fRemark != null">#{fRemark},</if>
        </trim>
    </insert>

    <update id="updateTWarehouseFeeAgreementTypeBusiness" parameterType="TWarehouseFeeAgreementTypeBusiness">
        update t_warehouse_fee_agreement_type_business
        <trim prefix="SET" suffixOverrides=",">
            <if test="fWarehouseFeeAgreementTypeFId != null">f_warehouse_fee_agreement_type_f_id =
                #{fWarehouseFeeAgreementTypeFId},
            </if>
            <if test="fTFeeAgreementTypeFId != null">f_t_fee_agreement_type_f_id = #{fTFeeAgreementTypeFId},</if>
            <if test="fTFeeAgreementFTypeParentId != null">f_t_fee_agreement_f_type_parent_id =
                #{fTFeeAgreementFTypeParentId},
            </if>
            <if test="fFeeItem != null">f_fee_item = #{fFeeItem},</if>
            <if test="fComputingMethod != null">f_computing_method = #{fComputingMethod},</if>
            <if test="fReceiptPaymentType != null">f_receipt_payment_type = #{fReceiptPaymentType},</if>
            <if test="fGetValue != null">f_get_value = #{fGetValue},</if>
            <if test="fDelFlag != null">f_del_flag = #{fDelFlag},</if>
            <if test="fUpdateTime != null">f_update_time = #{fUpdateTime},</if>
            <if test="fUpdateBy != null">f_update_by = #{fUpdateBy},</if>
            <if test="fCreateTime != null">f_create_time = #{fCreateTime},</if>
            <if test="fCreateBy != null">f_create_by = #{fCreateBy},</if>
            <if test="fRemark != null">f_remark = #{fRemark},</if>
        </trim>
        where f_id = #{fId}
    </update>

    <delete id="deleteTWarehouseFeeAgreementTypeBusinessById" parameterType="Long">
        delete
        from t_warehouse_fee_agreement_type_business
        where f_id = #{fId}
    </delete>

    <delete id="deleteTWarehouseFeeAgreementTypeBusinessByIds" parameterType="String">
        delete from t_warehouse_fee_agreement_type_business where f_id in
        <foreach item="fId" collection="array" open="(" separator="," close=")">
            #{fId}
        </foreach>
    </delete>

</mapper>