<?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.inspect.metadata.robuavtask.mapper.BasedataPatrolRobUavTaskMapper">

    <resultMap type="BasedataPatrolRobUavTask" id="BasedataPatrolRobUavTaskResult">
        <result property="taskId" column="task_id"/>
        <result property="taskCode" column="task_code"/>
        <result property="taskName" column="task_name"/>
        <result property="taskExecTime" column="task_exec_time"/>
        <result property="taskFilePath" column="task_file_path"/>
        <result property="remark" column="remark"/>
    </resultMap>

    <sql id="selectBasedataPatrolRobUavTaskVo">
        select task_id,
               task_code,
               task_name,
               task_exec_time,
               task_file_path,
               remark
        from basedata_partol_robuav_task
    </sql>

    <select id="selectBasedataPatrolRobUavTaskList" parameterType="BasedataPatrolRobUavTask"
            resultMap="BasedataPatrolRobUavTaskResult">
        <include refid="selectBasedataPatrolRobUavTaskVo"/>
        <where>
            <if test="taskCode != null  and taskCode != ''">and task_code =
                #{taskCode}
            </if>
            <if test="taskName != null  and taskName != ''">and task_name like
                concat('%', #{taskName}, '%')
            </if>
            <if test="taskExecTime != null ">and task_exec_time = #{taskExecTime}</if>
            <if test="taskFilePath != null  and taskFilePath != ''">and
                task_file_path = #{taskFilePath}
            </if>
        </where>
    </select>

    <select id="selectBasedataPatrolRobUavTaskByPatrolRobUavTaskId" parameterType="Long"
            resultMap="BasedataPatrolRobUavTaskResult">
        <include refid="selectBasedataPatrolRobUavTaskVo"/>
        where task_id = #{taskId}
    </select>

    <insert id="insertBasedataPatrolRobUavTask" parameterType="BasedataPatrolRobUavTask" useGeneratedKeys="true"
            keyProperty="taskId">
        insert into basedata_partol_robuav_task
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="taskCode != null">task_code,</if>
            <if test="taskName != null">task_name,</if>
            <if test="taskExecTime != null">task_exec_time,</if>
            <if test="taskFilePath != null">task_file_path,</if>
            <if test="remark != null">remark,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="taskCode != null">#{taskCode},</if>
            <if test="taskName != null">#{taskName},</if>
            <if test="taskExecTime != null">#{taskExecTime},</if>
            <if test="taskFilePath != null">#{taskFilePath},</if>
            <if test="remark != null">#{remark},</if>
        </trim>
    </insert>

    <update id="updateBasedataPatrolRobUavTask" parameterType="BasedataPatrolRobUavTask">
        update basedata_partol_robuav_task
        <trim prefix="SET" suffixOverrides=",">
            <if test="taskCode != null">task_code = #{taskCode},</if>
            <if test="taskName != null">task_name = #{taskName},</if>
            <if test="taskExecTime != null">task_exec_time = #{taskExecTime},</if>
            <if test="taskFilePath != null">task_file_path = #{taskFilePath},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where task_id = #{taskId}
    </update>

    <delete id="deleteBasedataPatrolRobUavTaskByPatrolRobUavTaskId" parameterType="Long">
        delete
        from basedata_partol_robuav_task
        where task_id = #{taskId}
    </delete>

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