<?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.djhk.uav.airspace.mapper.AirplaneOperatorMapper">

    <resultMap type="com.djhk.uav.airspace.domain.AirplaneApplyOperator" id="AirplaneApplyResult">
        <result column="id"         property="id"/>
        <result column="airplane_apply_id" property="airplaneApplyId"/>
        <result column="operator_id"  property="operatorId"/>
    </resultMap>

    <sql id="selectAirplaneApplyVo">
        select id,
        airplane_apply_id,
        operator_id
        from
        airplane_apply_operator
    </sql>

    <select id="selectAirplaneOperatorApplyList" parameterType="Long" resultMap="AirplaneApplyResult">
        <include refid="selectAirplaneApplyVo"/>
        WHERE airplane_apply_id = #{airplaneApplyId}
    </select>

    <insert id="insertAirplaneOperatorApply" parameterType="com.djhk.uav.airspace.domain.AirplaneApplyOperator">
        insert into airplane_apply_operator
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="airplaneApplyId != null">airplane_apply_id, </if>
            <if test="operatorId != null">operator_id,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="airplaneApplyId != null">#{airplaneApplyId},</if>
            <if test="operatorId != null">#{operatorId},</if>
        </trim>
    </insert>

    <delete id="deleteAirplaneApplyByOperatorId" parameterType="Long">
        DELETE FROM airplane_apply_operator
        WHERE airplane_apply_id = #{airplaneApplyId}
    </delete>


</mapper>