<?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.shipping.mapper.TShipDealItemMapper">
    
    <resultMap type="TShipDealItem" id="TShipDealItemResult">
        <result property="fId"    column="f_id"    />
        <result property="fPid"    column="f_pid"    />
        <result property="fFeeId"    column="f_fee_id"    />
        <result property="fFeeName"    column="f_fee_name"    />
        <result property="fFeeunitId"    column="f_feeunit_id"    />
        <result property="fFeeunitName"    column="f_feeunit_name"    />
        <result property="fPrice"    column="f_price"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectTShipDealItemVo">
        select f_id, f_pid, f_fee_id, f_fee_name, f_feeunit_id, f_feeunit_name, f_price, create_by, create_time, update_by, update_time, remark from t_ship_deal_item
    </sql>

    <select id="selectTShipDealItemList" parameterType="TShipDealItem" resultMap="TShipDealItemResult">
        <include refid="selectTShipDealItemVo"/>
        <where>  
            <if test="fPid != null "> and f_pid = #{fPid}</if>
            <if test="fFeeId != null "> and f_fee_id = #{fFeeId}</if>
            <if test="fFeeName != null  and fFeeName != ''"> and f_fee_name like concat('%', #{fFeeName}, '%')</if>
            <if test="fFeeunitId != null "> and f_feeunit_id = #{fFeeunitId}</if>
            <if test="fFeeunitName != null  and fFeeunitName != ''"> and f_feeunit_name like concat('%', #{fFeeunitName}, '%')</if>
            <if test="fPrice != null "> and f_price = #{fPrice}</if>
        </where>
    </select>
    
    <select id="selectTShipDealItemById" parameterType="Long" resultMap="TShipDealItemResult">
        <include refid="selectTShipDealItemVo"/>
        where f_id = #{fId}
    </select>
        
    <insert id="insertTShipDealItem" parameterType="TShipDealItem" useGeneratedKeys="true" keyProperty="fId">
        insert into t_ship_deal_item
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fPid != null">f_pid,</if>
            <if test="fFeeId != null">f_fee_id,</if>
            <if test="fFeeName != null">f_fee_name,</if>
            <if test="fFeeunitId != null">f_feeunit_id,</if>
            <if test="fFeeunitName != null">f_feeunit_name,</if>
            <if test="fPrice != null">f_price,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fPid != null">#{fPid},</if>
            <if test="fFeeId != null">#{fFeeId},</if>
            <if test="fFeeName != null">#{fFeeName},</if>
            <if test="fFeeunitId != null">#{fFeeunitId},</if>
            <if test="fFeeunitName != null">#{fFeeunitName},</if>
            <if test="fPrice != null">#{fPrice},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateTShipDealItem" parameterType="TShipDealItem">
        update t_ship_deal_item
        <trim prefix="SET" suffixOverrides=",">
            <if test="fPid != null">f_pid = #{fPid},</if>
            <if test="fFeeId != null">f_fee_id = #{fFeeId},</if>
            <if test="fFeeName != null">f_fee_name = #{fFeeName},</if>
            <if test="fFeeunitId != null">f_feeunit_id = #{fFeeunitId},</if>
            <if test="fFeeunitName != null">f_feeunit_name = #{fFeeunitName},</if>
            <if test="fPrice != null">f_price = #{fPrice},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where f_id = #{fId}
    </update>

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

    <delete id="deleteTShipDealItemByIds" parameterType="String">
        delete from t_ship_deal_item where f_id in 
        <foreach item="fId" collection="array" open="(" separator="," close=")">
            #{fId}
        </foreach>
    </delete>
    <delete id="deleteTShipDealItemByPIds" parameterType="String">
        delete from t_ship_deal_item where f_pid in
        <foreach item="fId" collection="array" open="(" separator="," close=")">
            #{fId}
        </foreach>
    </delete>
    
</mapper>