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

    <resultMap type="com.djhk.uav.uav.model.UavOperatorAbility" id="UavOperatorAbilityResult">
        <result property="id"    column="id"    />
        <result property="uavOperatorId"    column="uav_operator_id"    />
        <result property="abilityName"    column="ability_name"    />
        <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"    />
    </resultMap>

    <sql id="selectUavOperatorAbilityVo">
        select id, uav_operator_id, ability_name, del_flag, create_by, create_time, update_by, update_time, remark from uav_operator_ability
    </sql>

    <select id="selectUavOperatorAbilityList" parameterType="com.djhk.uav.uav.model.UavOperatorAbility" resultMap="UavOperatorAbilityResult">
        <include refid="selectUavOperatorAbilityVo"/>
        <where>
            <if test="uavOperatorId != null "> and uav_operator_id = #{uavOperatorId}</if>
            <if test="abilityName != null  and abilityName != ''"> and ability_name like concat('%', #{abilityName}, '%')</if>
            <if test="delFlag != null  and delFlag != ''"> and del_flag = #{delFlag}</if>
        </where>
    </select>

    <select id="selectUavOperatorAbilityById" parameterType="Long" resultMap="UavOperatorAbilityResult">
        <include refid="selectUavOperatorAbilityVo"/>
        where id = #{id}
    </select>

    <insert id="insertUavOperatorAbility" parameterType="com.djhk.uav.uav.model.UavOperatorAbility" useGeneratedKeys="true" keyProperty="id">
        insert into uav_operator_ability
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="uavOperatorId != null">uav_operator_id,</if>
            <if test="abilityName != null">ability_name,</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>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="uavOperatorId != null">#{uavOperatorId},</if>
            <if test="abilityName != null">#{abilityName},</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>
         </trim>
    </insert>

    <update id="updateUavOperatorAbility" parameterType="com.djhk.uav.uav.model.UavOperatorAbility">
        update uav_operator_ability
        <trim prefix="SET" suffixOverrides=",">
            <if test="uavOperatorId != null">uav_operator_id = #{uavOperatorId},</if>
            <if test="abilityName != null">ability_name = #{abilityName},</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>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteUavOperatorAbilityById" parameterType="Long">
        delete from uav_operator_ability where id = #{id}
    </delete>

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