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

    <resultMap type="com.djhk.uav.uav.model.UavOrganizationDevice" id="UavOrganizationDeviceResult">
        <result property="id"    column="id"    />
        <result property="organizationNo"    column="organization_no"    />
        <result property="uavNum"    column="uav_num"    />
        <result property="uavType"    column="uav_type"    />
        <result property="uavName"    column="uav_name"    />
        <result property="mtow"    column="mtow"    />
        <result property="loadMode"    column="load_mode"    />
        <result property="delFlag"    column="del_flag"    />
        <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="remark"    column="remark"    />
        <result property="deleteTime"    column="delete_time"    />
        <result property="deleteBy"    column="delete_by"    />
    </resultMap>

    <sql id="selectUavOrganizationDeviceVo">
        select id, organization_no, uav_num, uav_type, uav_name, mtow, load_mode, del_flag, create_by, create_time, update_by, update_time, remark, delete_time, delete_by from uav_organization_device
    </sql>

    <select id="selectUavOrganizationDeviceList" parameterType="com.djhk.uav.uav.model.UavOrganizationDevice" resultMap="UavOrganizationDeviceResult">
        <include refid="selectUavOrganizationDeviceVo"/>
        <where>
            <if test="organizationNo != null  and organizationNo != ''"> and organization_no = #{organizationNo}</if>
            <if test="uavNum != null  and uavNum != ''"> and uav_num = #{uavNum}</if>
            <if test="uavType != null  and uavType != ''"> and uav_type = #{uavType}</if>
            <if test="uavName != null  and uavName != ''"> and uav_name like concat('%', #{uavName}, '%')</if>
            <if test="mtow != null  and mtow != ''"> and mtow = #{mtow}</if>
            <if test="loadMode != null "> and load_mode = #{loadMode}</if>
            <if test="deleteTime != null "> and delete_time = #{deleteTime}</if>
            <if test="deleteBy != null  and deleteBy != ''"> and delete_by = #{deleteBy}</if>
        </where>
    </select>

    <select id="selectUavOrganizationDeviceById" parameterType="Long" resultMap="UavOrganizationDeviceResult">
        <include refid="selectUavOrganizationDeviceVo"/>
        where id = #{id}
    </select>

    <insert id="insertUavOrganizationDevice" parameterType="com.djhk.uav.uav.model.UavOrganizationDevice" useGeneratedKeys="true" keyProperty="id">
        insert into uav_organization_device
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="organizationNo != null">organization_no,</if>
            <if test="uavNum != null">uav_num,</if>
            <if test="uavType != null">uav_type,</if>
            <if test="uavName != null">uav_name,</if>
            <if test="mtow != null">mtow,</if>
            <if test="loadMode != null">load_mode,</if>
            <if test="delFlag != null">del_flag,</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="remark != null">remark,</if>
            <if test="deleteTime != null">delete_time,</if>
            <if test="deleteBy != null">delete_by,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="organizationNo != null">#{organizationNo},</if>
            <if test="uavNum != null">#{uavNum},</if>
            <if test="uavType != null">#{uavType},</if>
            <if test="uavName != null">#{uavName},</if>
            <if test="mtow != null">#{mtow},</if>
            <if test="loadMode != null">#{loadMode},</if>
            <if test="delFlag != null">#{delFlag},</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="remark != null">#{remark},</if>
            <if test="deleteTime != null">#{deleteTime},</if>
            <if test="deleteBy != null">#{deleteBy},</if>
         </trim>
    </insert>

    <update id="updateUavOrganizationDevice" parameterType="com.djhk.uav.uav.model.UavOrganizationDevice">
        update uav_organization_device
        <trim prefix="SET" suffixOverrides=",">
            <if test="organizationNo != null">organization_no = #{organizationNo},</if>
            <if test="uavNum != null">uav_num = #{uavNum},</if>
            <if test="uavType != null">uav_type = #{uavType},</if>
            <if test="uavName != null">uav_name = #{uavName},</if>
            <if test="mtow != null">mtow = #{mtow},</if>
            <if test="loadMode != null">load_mode = #{loadMode},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</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>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="deleteTime != null">delete_time = #{deleteTime},</if>
            <if test="deleteBy != null">delete_by = #{deleteBy},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteUavOrganizationDeviceById" parameterType="Long">
        delete from uav_organization_device where id = #{id}
    </delete>

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