<?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.AirplaneAirspaceMapper">

    <resultMap type="com.djhk.uav.airspace.domain.AirplaneApplyAirspace" id="AirplaneApplyResult">
        <result column="id"         property="id"/>
        <result column="airplane_apply_id" property="airplaneApplyId"/>
        <result column="airspace_id"  property="airspaceId"/>
    </resultMap>

    <sql id="selectAirplaneApplyVo">
        select id,
        airplane_apply_id,
        airspace_id
        from
        airplane_apply_airspace
    </sql>

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

    <insert id="insertAirplaneAirspaceApply" parameterType="com.djhk.uav.airspace.domain.AirplaneApplyAirplane">
        insert into airplane_apply_airspace
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="airplaneApplyId != null">airplane_apply_id, </if>
            <if test="airspaceId != null">airspace_id,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="airplaneApplyId != null">#{airplaneApplyId},</if>
            <if test="airspaceId != null">#{airspaceId},</if>
        </trim>
    </insert>

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


</mapper>