<?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.UavpsMultiTargetFormationMapper">
    
    <resultMap type="UavpsMultiTargetFormation" id="UavpsMultiTargetFormationResult">
        <result property="id"    column="id"    />
        <result property="targetId"    column="target_id"    />
        <result property="longitude"    column="longitude"    />
        <result property="latitude"    column="latitude"    />
        <result property="altitude"    column="altitude"    />
        <result property="eastSpeed"    column="east_speed"    />
        <result property="northSpeed"    column="north_speed"    />
        <result property="skySpeed"    column="sky_speed"    />
        <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="selectUavpsMultiTargetFormationVo">
        select id, target_id, longitude, latitude, altitude, east_speed, north_speed, sky_speed, utc_times, create_by, create_time, update_by, update_time from uavps_multi_target_formation
    </sql>

    <select id="selectUavpsMultiTargetFormationList" parameterType="UavpsMultiTargetFormation" resultMap="UavpsMultiTargetFormationResult">
        <include refid="selectUavpsMultiTargetFormationVo"/>
        <where>
            <if test="targetId != null "> and target_id = #{targetId}</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="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="utcTimes != null "> and utc_times = #{utcTimes}</if>
        </where>
    </select>
    
    <select id="selectUavpsMultiTargetFormationById" parameterType="Long" resultMap="UavpsMultiTargetFormationResult">
        <include refid="selectUavpsMultiTargetFormationVo"/>
        where id = #{id}
    </select>

    <insert id="insertUavpsMultiTargetFormation" parameterType="UavpsMultiTargetFormation" useGeneratedKeys="true" keyProperty="id">
        insert into uavps_multi_target_formation
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="targetId != null">target_id,</if>
            <if test="longitude != null">longitude,</if>
            <if test="latitude != null">latitude,</if>
            <if test="altitude != null">altitude,</if>
            <if test="eastSpeed != null">east_speed,</if>
            <if test="northSpeed != null">north_speed,</if>
            <if test="skySpeed != null">sky_speed,</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="targetId != null">#{targetId},</if>
            <if test="longitude != null">#{longitude},</if>
            <if test="latitude != null">#{latitude},</if>
            <if test="altitude != null">#{altitude},</if>
            <if test="eastSpeed != null">#{eastSpeed},</if>
            <if test="northSpeed != null">#{northSpeed},</if>
            <if test="skySpeed != null">#{skySpeed},</if>
            <if test="utcTimes != null">#{utcTimes},</if>
            <if test="createBy != null">#{createBy},</if>
            sysdate()
         </trim>
    </insert>

    <update id="updateUavpsMultiTargetFormation" parameterType="UavpsMultiTargetFormation">
        update uavps_multi_target_formation
        <trim prefix="SET" suffixOverrides=",">
            <if test="targetId != null">target_id = #{targetId},</if>
            <if test="longitude != null">longitude = #{longitude},</if>
            <if test="latitude != null">latitude = #{latitude},</if>
            <if test="altitude != null">altitude = #{altitude},</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="utcTimes != null">utc_times = #{utcTimes},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            update_time = sysdate()
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteUavpsMultiTargetFormationById" parameterType="Long">
        delete from uavps_multi_target_formation where id = #{id}
    </delete>

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

    <select id="selectByTargetId" parameterType="long" resultMap="UavpsMultiTargetFormationResult">
        <include refid="selectUavpsMultiTargetFormationVo"/>
        where target_id = #{targetId}
    </select>

    <select id="selectUavpsMultiTargetFormationAll" resultMap="UavpsMultiTargetFormationResult">
        <include refid="selectUavpsMultiTargetFormationVo"/>
    </select>
</mapper>