<?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.uavps.system.mapper.UavpsAircraftMapper">
    
    <resultMap type="UavpsAircraft" id="UavpsAircraftResult">
        <result property="bizId"    column="bizId"    />
        <result property="dataTime"    column="data_time"    />
        <result property="aircraftData"    column="aircraft_data"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectUavpsAircraftVo">
        select bizId, data_time, aircraft_data, create_by, create_time, update_by, update_time from uavps_aircraft
    </sql>

    <select id="selectUavpsAircraftList" parameterType="UavpsAircraft" resultMap="UavpsAircraftResult">
        <include refid="selectUavpsAircraftVo"/>
        <where>  
            <if test="aircraftData != null  and aircraftData != ''"> and aircraft_data = #{aircraftData}</if>
        </where>
    </select>
    
    <select id="selectUavpsAircraftByBizId" parameterType="String" resultMap="UavpsAircraftResult">
        <include refid="selectUavpsAircraftVo"/>
        where bizId = #{bizId} order by data_time
    </select>

    <insert id="insertUavpsAircraft" parameterType="UavpsAircraft">
        insert into uavps_aircraft
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="bizId != null">bizId,</if>
            <if test="dataTime != null">data_time,</if>
            <if test="aircraftData != null and aircraftData != ''">aircraft_data,</if>
            <if test="createBy != null">create_by,</if>
            create_time
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="bizId != null">#{bizId},</if>
            <if test="dataTime != null">#{dataTime},</if>
            <if test="aircraftData != null and aircraftData != ''">#{aircraftData},</if>
            <if test="createBy != null">#{createBy},</if>
            sysdate()
         </trim>
    </insert>

    <update id="updateUavpsAircraft" parameterType="UavpsAircraft">
        update uavps_aircraft
        <trim prefix="SET" suffixOverrides=",">
            <if test="dataTime != null">data_time = #{dataTime},</if>
            <if test="aircraftData != null and aircraftData != ''">aircraft_data = #{aircraftData},</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>
            update_time = sysdate()
        </trim>
        where bizId = #{bizId}
    </update>

    <delete id="deleteUavpsAircraftByBizId" parameterType="String">
        delete from uavps_aircraft where bizId = #{bizId}
    </delete>

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