<?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.sundot.airport.blocked.mapper.BlockedRateMapper">

    <resultMap type="BlockedRate" id="BlockedRateResult">
        <result property="tenantId" column="tenant_id"/>
        <result property="revision" column="revision"/>
        <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"/>
        <result property="id" column="id"/>
        <result property="statDate" column="stat_date"/>
        <result property="travelInspectionDomesticAvgRatePeak" column="travel_inspection_domestic_avg_rate_peak"/>
        <result property="dutyBrigadeId" column="duty_brigade_id"/>
        <result property="dutyBrigadeName" column="duty_brigade_name"/>
        <result property="t1AAreaRatePeak" column="t1_a_area_rate_peak"/>
        <result property="t1BAreaRatePeak" column="t1_b_area_rate_peak"/>
        <result property="t2DomesticRatePeak" column="t2_domestic_rate_peak"/>
        <result property="t2InternationalRatePeak" column="t2_international_rate_peak"/>
        <result property="shift" column="shift"/>
        <result property="t2TransferRatePeak" column="t2_transfer_rate_peak"/>
        <result property="internationalTransferAvgRatePeak" column="international_transfer_avg_rate_peak"/>
    </resultMap>

    <sql id="selectItemSeizureRateVo">
        select tenant_id,
               revision,
               create_by,
               create_time,
               update_by,
               update_time,
               remark,
               id,
               stat_date,
               travel_inspection_domestic_avg_rate_peak,
               duty_brigade_id,
               duty_brigade_name,
               t1_a_area_rate_peak,
               t1_b_area_rate_peak,
               t2_domestic_rate_peak,
               t2_international_rate_peak,
               shift,
               t2_transfer_rate_peak,
               international_transfer_avg_rate_peak
        from blocked_rate
    </sql>

    <select id="selectBlockedRateList" parameterType="BlockedRate" resultMap="BlockedRateResult">
        <include refid="selectItemSeizureRateVo"/>
        <where>
            <if test="tenantId != null  and tenantId != ''">and tenant_id = #{tenantId}</if>
            <if test="revision != null ">and revision = #{revision}</if>
            <if test="statDate != null ">and stat_date = #{statDate}</if>
            <if test="travelInspectionDomesticAvgRatePeak != null ">and travel_inspection_domestic_avg_rate_peak =
                #{travelInspectionDomesticAvgRatePeak}
            </if>
            <if test="dutyBrigadeId != null ">and duty_brigade_id = #{dutyBrigadeId}</if>
            <if test="dutyBrigadeName != null  and dutyBrigadeName != ''">and duty_brigade_name like concat('%',
                #{dutyBrigadeName}, '%')
            </if>
            <if test="t1AAreaRatePeak != null ">and t1_a_area_rate_peak = #{t1AAreaRatePeak}</if>
            <if test="t1BAreaRatePeak != null ">and t1_b_area_rate_peak = #{t1BAreaRatePeak}</if>
            <if test="t2DomesticRatePeak != null ">and t2_domestic_rate_peak = #{t2DomesticRatePeak}</if>
            <if test="t2InternationalRatePeak != null ">and t2_international_rate_peak = #{t2InternationalRatePeak}</if>
            <if test="shift != null  and shift != ''">and shift = #{shift}</if>
            <if test="t2TransferRatePeak != null ">and t2_transfer_rate_peak = #{t2TransferRatePeak}</if>
            <if test="internationalTransferAvgRatePeak != null ">and international_transfer_avg_rate_peak =
                #{internationalTransferAvgRatePeak}
            </if>
        </where>
    </select>

    <select id="selectBlockedRateById" parameterType="Long" resultMap="BlockedRateResult">
        <include refid="selectItemSeizureRateVo"/>
        where id = #{id}
    </select>

    <insert id="insertBlockedRate" parameterType="BlockedRate" useGeneratedKeys="true" keyProperty="id">
        insert into blocked_rate
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="tenantId != null">tenant_id,</if>
            <if test="revision != null">revision,</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>
            <if test="statDate != null">stat_date,</if>
            <if test="travelInspectionDomesticAvgRatePeak != null">travel_inspection_domestic_avg_rate_peak,</if>
            <if test="dutyBrigadeId != null">duty_brigade_id,</if>
            <if test="dutyBrigadeName != null and dutyBrigadeName != ''">duty_brigade_name,</if>
            <if test="t1AAreaRatePeak != null">t1_a_area_rate_peak,</if>
            <if test="t1BAreaRatePeak != null">t1_b_area_rate_peak,</if>
            <if test="t2DomesticRatePeak != null">t2_domestic_rate_peak,</if>
            <if test="t2InternationalRatePeak != null">t2_international_rate_peak,</if>
            <if test="shift != null and shift != ''">shift,</if>
            <if test="t2TransferRatePeak != null">t2_transfer_rate_peak,</if>
            <if test="internationalTransferAvgRatePeak != null">international_transfer_avg_rate_peak,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="tenantId != null">#{tenantId},</if>
            <if test="revision != null">#{revision},</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>
            <if test="statDate != null">#{statDate},</if>
            <if test="travelInspectionDomesticAvgRatePeak != null">#{travelInspectionDomesticAvgRatePeak},</if>
            <if test="dutyBrigadeId != null">#{dutyBrigadeId},</if>
            <if test="dutyBrigadeName != null and dutyBrigadeName != ''">#{dutyBrigadeName},</if>
            <if test="t1AAreaRatePeak != null">#{t1AAreaRatePeak},</if>
            <if test="t1BAreaRatePeak != null">#{t1BAreaRatePeak},</if>
            <if test="t2DomesticRatePeak != null">#{t2DomesticRatePeak},</if>
            <if test="t2InternationalRatePeak != null">#{t2InternationalRatePeak},</if>
            <if test="shift != null and shift != ''">#{shift},</if>
            <if test="t2TransferRatePeak != null">#{t2TransferRatePeak},</if>
            <if test="internationalTransferAvgRatePeak != null">#{internationalTransferAvgRatePeak},</if>
        </trim>
    </insert>

    <update id="updateBlockedRate" parameterType="BlockedRate">
        update blocked_rate
        <trim prefix="SET" suffixOverrides=",">
            <if test="tenantId != null">tenant_id = #{tenantId},</if>
            <if test="revision != null">revision = #{revision},</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>
            <if test="statDate != null">stat_date = #{statDate},</if>
            <if test="travelInspectionDomesticAvgRatePeak != null">travel_inspection_domestic_avg_rate_peak =
                #{travelInspectionDomesticAvgRatePeak},
            </if>
            <if test="dutyBrigadeId != null">duty_brigade_id = #{dutyBrigadeId},</if>
            <if test="dutyBrigadeName != null and dutyBrigadeName != ''">duty_brigade_name = #{dutyBrigadeName},</if>
            <if test="t1AAreaRatePeak != null">t1_a_area_rate_peak = #{t1AAreaRatePeak},</if>
            <if test="t1BAreaRatePeak != null">t1_b_area_rate_peak = #{t1BAreaRatePeak},</if>
            <if test="t2DomesticRatePeak != null">t2_domestic_rate_peak = #{t2DomesticRatePeak},</if>
            <if test="t2InternationalRatePeak != null">t2_international_rate_peak = #{t2InternationalRatePeak},</if>
            <if test="shift != null and shift != ''">shift = #{shift},</if>
            <if test="t2TransferRatePeak != null">t2_transfer_rate_peak = #{t2TransferRatePeak},</if>
            <if test="internationalTransferAvgRatePeak != null">international_transfer_avg_rate_peak =
                #{internationalTransferAvgRatePeak},
            </if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBlockedRateById" parameterType="Long">
        delete
        from blocked_rate
        where id = #{id}
    </delete>

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