<?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.base.biz.mapper.FzTaskInfoMapper">

    <select id="getFzTaskInfoList" parameterType="com.base.biz.model.dto.request.FzTaskInfoReqDTO"
            resultType="com.base.biz.model.entity.FzTaskInfo">
        select * from fz_task_info
        <where>
            <if test="req.steps !=null and req.steps.size()>0">
                and fz_task_step in
                <foreach collection="req.steps" index="index" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="req.reqIds !=null and req.reqIds.size()>0">
                and req_id in
                <foreach collection="req.reqIds" index="index" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="req.priorityStart != null">
                and priority &gt;= #{req.priorityStart}
            </if>
            <if test="req.priorityEnd != null">
                and priority &lt;= #{req.priorityEnd}
            </if>
            <if test="req.startTime != null">
                and req_start_time &gt;= #{req.startTime}
            </if>
            <if test="req.endTime != null">
                and req_end_time &lt;= #{req.endTime}
            </if>
            <if test="req.fzTaskState !=null and req.fzTaskState != ''">
                and fz_task_state =#{req.fzTaskState}
            </if>
        </where>
        order by priority
    </select>

    <update id="updateTaskInfo" parameterType="com.base.biz.model.dto.request.FzTaskInfoUpdateDTO">
        update fz_task_info
        <set>
            <if test="req.fzTaskState!=null ">
                fz_task_state = #{req.fzTaskState}
            </if>
            <if test="req.payloadIds!=null ">
                ,payload_ids = #{req.payloadIds}
            </if>
        </set>
        where id = #{req.id}
    </update>

    <update id="updateTaskStepState" parameterType="com.base.api.model.request.TaskStateNotice">
        update fz_task_info
        <set>
            <if test="req.state!=null ">
                fz_task_state = #{req.state}
            </if>
            <if test="req.step!=null ">
                ,fz_task_step = #{req.step}
            </if>
        </set>
        where req_id = #{req.bizTaskId}
    </update>

</mapper>