<?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.ruoyi.manage.mapper.TaskManageMapper">
    
    <resultMap type="TaskManage" id="TaskManageResult">
        <result property="taskId"    column="task_id"    />
        <result property="taskNum"    column="task_num"    />
        <result property="taskDetails"    column="task_details"    />
        <result property="channelId"    column="channel_id"    />
        <result property="videoAddress"    column="video_address"    />
        <result property="reportAddress"    column="report_address"    />
        <result property="algorithmSet"    column="algorithm_set"    />
        <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="selectTaskManageVo">
        select task_id, task_num, task_details, channel_id, video_address, report_address, algorithm_set, del_flag, create_by, create_time, update_by, update_time, remark from task_manage
    </sql>

    <select id="selectTaskManageList" parameterType="TaskManage" resultMap="TaskManageResult">
        <include refid="selectTaskManageVo"/>
        <where>  
            <if test="taskNum != null  and taskNum != ''"> and task_num = #{taskNum}</if>
            <if test="taskDetails != null  and taskDetails != ''"> and task_details = #{taskDetails}</if>
            <if test="channelId != null "> and channel_id = #{channelId}</if>
            <if test="videoAddress != null  and videoAddress != ''"> and video_address = #{videoAddress}</if>
            <if test="reportAddress != null  and reportAddress != ''"> and report_address = #{reportAddress}</if>
            <if test="algorithmSet != null  and algorithmSet != ''"> and algorithm_set = #{algorithmSet}</if>
        </where>
    </select>
    
    <select id="selectTaskManageByTaskId" parameterType="Long" resultMap="TaskManageResult">
        <include refid="selectTaskManageVo"/>
        where task_id = #{taskId}
    </select>

    <insert id="insertTaskManage" parameterType="TaskManage" useGeneratedKeys="true" keyProperty="taskId">
        insert into task_manage
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="taskNum != null">task_num,</if>
            <if test="taskDetails != null">task_details,</if>
            <if test="channelId != null">channel_id,</if>
            <if test="videoAddress != null">video_address,</if>
            <if test="reportAddress != null">report_address,</if>
            <if test="algorithmSet != null">algorithm_set,</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="taskNum != null">#{taskNum},</if>
            <if test="taskDetails != null">#{taskDetails},</if>
            <if test="channelId != null">#{channelId},</if>
            <if test="videoAddress != null">#{videoAddress},</if>
            <if test="reportAddress != null">#{reportAddress},</if>
            <if test="algorithmSet != null">#{algorithmSet},</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="updateTaskManage" parameterType="TaskManage">
        update task_manage
        <trim prefix="SET" suffixOverrides=",">
            <if test="taskNum != null">task_num = #{taskNum},</if>
            <if test="taskDetails != null">task_details = #{taskDetails},</if>
            <if test="channelId != null">channel_id = #{channelId},</if>
            <if test="videoAddress != null">video_address = #{videoAddress},</if>
            <if test="reportAddress != null">report_address = #{reportAddress},</if>
            <if test="algorithmSet != null">algorithm_set = #{algorithmSet},</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 task_id = #{taskId}
    </update>

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

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