<?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.UavpsUnmannedAerialVehicleMapper">
    
    <resultMap type="UavpsUnmannedAerialVehicle" id="UavpsUnmannedAerialVehicleResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="longitude"    column="longitude"    />
        <result property="latitude"    column="latitude"    />
        <result property="altitude"    column="altitude"    />
        <result property="azimuthAngle"    column="azimuth_angle"    />
        <result property="pitchAngle"    column="pitch_angle"    />
        <result property="rollAngle"    column="roll_angle"    />
        <result property="eastSpeed"    column="east_speed"    />
        <result property="northSpeed"    column="north_speed"    />
        <result property="skySpeed"    column="sky_speed"    />
        <result property="trackAngle"    column="track_angle"    />
        <result property="utcTimes"    column="utc_times"    />
        <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="selectUavpsUnmannedAerialVehicleVo">
        select id, name, longitude, latitude, altitude, azimuth_angle, pitch_angle, roll_angle, east_speed, north_speed, sky_speed, track_angle, utc_times, create_by, create_time, update_by, update_time from uavps_unmanned_aerial_vehicle
    </sql>

    <select id="selectUavpsUnmannedAerialVehicleList" parameterType="UavpsUnmannedAerialVehicle" resultMap="UavpsUnmannedAerialVehicleResult">
        <include refid="selectUavpsUnmannedAerialVehicleVo"/>
        <where>
            <if test="name != null and name != ''">
                AND name like concat('%', #{name}, '%')
            </if>
            <if test="longitude != null "> and longitude = #{longitude}</if>
            <if test="latitude != null "> and latitude = #{latitude}</if>
            <if test="altitude != null "> and altitude = #{altitude}</if>
            <if test="azimuthAngle != null "> and azimuth_angle = #{azimuthAngle}</if>
            <if test="pitchAngle != null "> and pitch_angle = #{pitchAngle}</if>
            <if test="rollAngle != null "> and roll_angle = #{rollAngle}</if>
            <if test="eastSpeed != null "> and east_speed = #{eastSpeed}</if>
            <if test="northSpeed != null "> and north_speed = #{northSpeed}</if>
            <if test="skySpeed != null "> and sky_speed = #{skySpeed}</if>
            <if test="trackAngle != null "> and track_angle = #{trackAngle}</if>
            <if test="utcTimes != null "> and utc_times = #{utcTimes}</if>
        </where>
    </select>
    
    <select id="selectUavpsUnmannedAerialVehicleById" parameterType="Long" resultMap="UavpsUnmannedAerialVehicleResult">
        <include refid="selectUavpsUnmannedAerialVehicleVo"/>
        where id = #{id}
    </select>

    <insert id="insertUavpsUnmannedAerialVehicle" parameterType="UavpsUnmannedAerialVehicle" useGeneratedKeys="true" keyProperty="id">
        insert into uavps_unmanned_aerial_vehicle
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null and name != ''">name,</if>
            <if test="longitude != null">longitude,</if>
            <if test="latitude != null">latitude,</if>
            <if test="altitude != null">altitude,</if>
            <if test="azimuthAngle != null">azimuth_angle,</if>
            <if test="pitchAngle != null">pitch_angle,</if>
            <if test="rollAngle != null">roll_angle,</if>
            <if test="eastSpeed != null">east_speed,</if>
            <if test="northSpeed != null">north_speed,</if>
            <if test="skySpeed != null">sky_speed,</if>
            <if test="trackAngle != null">track_angle,</if>
            <if test="utcTimes != null">utc_times,</if>
            <if test="createBy != null">create_by,</if>
            create_time
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null and name != ''">#{name},</if>
            <if test="longitude != null">#{longitude},</if>
            <if test="latitude != null">#{latitude},</if>
            <if test="altitude != null">#{altitude},</if>
            <if test="azimuthAngle != null">#{azimuthAngle},</if>
            <if test="pitchAngle != null">#{pitchAngle},</if>
            <if test="rollAngle != null">#{rollAngle},</if>
            <if test="eastSpeed != null">#{eastSpeed},</if>
            <if test="northSpeed != null">#{northSpeed},</if>
            <if test="skySpeed != null">#{skySpeed},</if>
            <if test="trackAngle != null">#{trackAngle},</if>
            <if test="utcTimes != null">#{utcTimes},</if>
            <if test="createBy != null">#{createBy},</if>
            sysdate()
         </trim>
    </insert>

    <update id="updateUavpsUnmannedAerialVehicle" parameterType="UavpsUnmannedAerialVehicle">
        update uavps_unmanned_aerial_vehicle
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null and name != ''">name = #{name},</if>
            <if test="longitude != null">longitude = #{longitude},</if>
            <if test="latitude != null">latitude = #{latitude},</if>
            <if test="altitude != null">altitude = #{altitude},</if>
            <if test="azimuthAngle != null">azimuth_angle = #{azimuthAngle},</if>
            <if test="pitchAngle != null">pitch_angle = #{pitchAngle},</if>
            <if test="rollAngle != null">roll_angle = #{rollAngle},</if>
            <if test="eastSpeed != null">east_speed = #{eastSpeed},</if>
            <if test="northSpeed != null">north_speed = #{northSpeed},</if>
            <if test="skySpeed != null">sky_speed = #{skySpeed},</if>
            <if test="trackAngle != null">track_angle = #{trackAngle},</if>
            <if test="utcTimes != null">utc_times = #{utcTimes},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            update_time = sysdate()
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteUavpsUnmannedAerialVehicleById" parameterType="Long">
        delete from uavps_unmanned_aerial_vehicle where id = #{id}
    </delete>

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

    <select id="selectByName" parameterType="String" resultMap="UavpsUnmannedAerialVehicleResult">
        <include refid="selectUavpsUnmannedAerialVehicleVo"/>
        where name = trim(#{name})
    </select>

    <select id="selectUavpsUavAll" resultMap="UavpsUnmannedAerialVehicleResult">
        <include refid="selectUavpsUnmannedAerialVehicleVo"/>
    </select>
</mapper>