<?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.uav.mapper.UavRealInfoMapper">
    
    <resultMap type="com.djhk.uav.uav.model.UavRealInfo" id="UavRealInfoResult">
        <result property="id"    column="id"    />
        <result property="uavId"    column="uav_id"    />
        <result property="uavType"    column="uav_type"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="detectSituation"    column="detect_situation"    />
        <result property="JSR"    column="JSR"    />
    </resultMap>

    <sql id="selectUavRealInfoVo">
        select id, uav_id, uav_type, create_by, create_time, update_by, update_time, detect_situation, JSR from uav_real_information
    </sql>

    <select id="selectUavRealInfoList" parameterType="com.djhk.uav.uav.model.UavRealInfo" resultMap="UavRealInfoResult">
        <include refid="selectUavRealInfoVo"/>
        <where>  
            <if test="uavType != null  and uavType != ''"> and uav_type like concat('%', #{uavType}, '%')</if>
            <if test="uavId != null  and uavId != ''"> and uav_id = #{uavId}</if>
            <if test="detectSituation != null  and detectSituation != ''"> and detect_situation = #{detectSituation}</if>
            <if test="JSR != null  and JSR != ''"> and JSR = #{JSR}</if>
        </where>
    </select>
    
    <select id="selectUavRealInfoByUavId" parameterType="Long" resultMap="UavRealInfoResult">
        <include refid="selectUavRealInfoVo"/>
        where id = #{id}
    </select>


    <insert id="insertUavRealInfo" parameterType="com.djhk.uav.uav.model.UavRealInfo" useGeneratedKeys="true" keyProperty="id">
        insert into uav_real_information
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="uavType != null">uav_type,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="uavId != null">uav_id,</if>
            <if test="detectSituation != null">detect_situation,</if>
            <if test="JSR != null">JSR,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="uavType != null">#{uavType},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="uavId != null">#{uavId},</if>
            <if test="detectSituation != null">#{detectSituation},</if>
            <if test="JSR != null">#{JSR},</if>
         </trim>
    </insert>

    <update id="updateUavRealInfo" parameterType="com.djhk.uav.uav.model.UavRealInfo">
        update uav_real_information
        <trim prefix="SET" suffixOverrides=",">
            <if test="uavType != null">uav_type = #{uavType},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="detectSituation != null">detect_situation = #{detectSituation},</if>
            <if test="JSR != null">JSR = #{JSR},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteUavRealInfoByUavId" parameterType="Long">
        delete from uav_real_information where id = #{id}
    </delete>

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