package com.mortals.xhx.feign.flowable;

import com.mortals.xhx.common.pdu.flow.FlowNextPdu;
import com.mortals.xhx.common.pdu.flow.FlowUserTaskPdu;
import com.mortals.xhx.feign.IFeign;
import com.mortals.xhx.feign.req.BaseFlowReq;
import com.mortals.xhx.feign.req.BaseQuery;
import com.mortals.xhx.feign.rsp.ApiResp;
import com.mortals.xhx.feign.rsp.TaskRsp;
import com.mortals.xhx.feign.task.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;
import java.util.Map;

/**
 * 工作流任务管理
 *
 * @author: finegirl
 * @date: 2021/7/31 19:52
 */
@FeignClient(name = "workflow-manager",path = "/m")
public interface IApiFlowTaskFeign extends IFeign {

    /**
     * 我发起的流程
     *
     * @param req
     * @return
     */
    @PostMapping("/api/flow/task/myProcess")
    ApiResp<TaskRsp> myProcess(@RequestBody BaseFlowReq<BaseQuery> req);


    /**
     * 获取待办列表
     * 获取的列表需要和业务系统数据合并
     *
     * @param req
     * @return
     */
    @PostMapping("/api/flow/task/todoList")
    ApiResp<TaskRsp> todoList(@RequestBody BaseFlowReq<BaseQuery> req);


    /**
     * 获取已办任务
     * 获取的列表需要和业务系统数据合并
     *
     * @param req
     * @return
     */
    @PostMapping("/api/flow/task/finishedList")
    ApiResp<TaskRsp> finishedList(@RequestBody BaseFlowReq<BaseQuery> req);


    /**
     * 流程历史流转记录
     *
     * @param req
     * @return
     */
    @PostMapping("/api/flow/task/flowRecord")
    ApiResp<TaskRsp> flowRecord(@RequestBody BaseFlowReq<BaseQuery> req);


    /**
     * 获取流程变量
     *
     * @param req
     * @return
     */
    @PostMapping("/api/flow/task/processVariables")
    ApiResp<Map<String, Object>> processVariables(@RequestBody CommonTaskReq req);



    /**
     * 设置流程变量
     *
     * @param req
     * @return
     */
    @PostMapping("/api/flow/task/setProcessVariables")
    ApiResp<Map<String, Object>> setProcessVariables(@RequestBody CommonTaskReq req);



    /**
     * 撤回流程
     *
     * @param req
     * @return
     */
    @PostMapping("/api/flow/task/revokeProcess")
    ApiResp revokeProcess(@RequestBody RevokeTaskReq req);

    /**
     * 取消申请
     *
     * @param commonTaskReq
     * @return
     */
    @PostMapping("/api/flow/task/stopProcess")
    ApiResp stopProcess(@RequestBody CommonTaskReq commonTaskReq);

    /**
     * 审批任务
     *
     * @param req
     * @return
     */
    @PostMapping("/api/flow/task/complete")
    ApiResp<String> complete(@RequestBody CompleteTaskReq req);


    /**
     * 驳回任务
     *
     * @param req
     * @return
     */
    @PostMapping("/api/flow/task/reject")
    ApiResp<String> reject(@RequestBody RejectTaskReq req);


    /**
     * 退回任务
     *
     * @param req
     * @return
     */
    @PostMapping("/api/flow/task/return")
    ApiResp<String> taskReturn(@RequestBody ReturnTaskReq req);


    /**
     * 删除任务
     *
     * @param req
     * @return
     */
    @PostMapping("/api/flow/task/delete")
    ApiResp<String> delete(@RequestBody DeleteTaskReq req);

    /**
     * 委派任务
     *
     * @param req
     * @return
     */
    @PostMapping("/api/flow/task/delegate")
    ApiResp<String> delegateTask(@RequestBody DelegateTaskReq req);

    /**
     * 转办任务
     *
     * @param req
     * @return
     */
    @PostMapping("/api/flow/task/assign")
    ApiResp<String> assignTask(@RequestBody TurnTaskReq req);


    /**
     * 加签任务
     *
     * @param req
     * @return
     */
    @PostMapping("/api/flow/task/addSign")
    ApiResp<String> addSignTask(@RequestBody AddSignTaskReq req);

    /**
     * 获取所有可回退的节点
     *
     * @param req
     * @return
     */
    @PostMapping("/api/flow/task/findReturnTaskList")
    ApiResp<List<FlowUserTaskPdu>> findReturnTaskList(@RequestBody CommonTaskReq req);


    /**
     * 获取下一节点
     *
     * @param req
     * @return
     */
    @PostMapping("/api/flow/task/nextFlowNode")
    ApiResp<FlowNextPdu> nextFlowNode(@RequestBody CommonTaskReq req);
}

