package com.mortals.xhx.feign.flowable;

import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
import com.mortals.xhx.common.pdu.api.ApiRespPdu;
import com.mortals.xhx.common.pdu.flow.*;
import com.mortals.xhx.feign.IFeign;
import com.mortals.xhx.flowable.task.*;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;

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

/**
 * 工作流任务管理
 *
 * @author: finegirl
 * @date: 2021/7/31 19:52
 */
@FeignClient(name = "${application.register.service-name:workflow-engine}")
public interface IApiFlowTaskFeign extends IFeign {


    /**
     * 我发起的流程
     *
     * @param commonTaskReq
     * @return
     */
    @PostMapping("/flowable/task/myProcess")
    ApiRespPdu<Result<FlowTaskPdu>> myProcess(@RequestBody CommonTaskReq commonTaskReq);


    /**
     * 获取待办列表
     * 获取的列表需要和业务系统数据合并
     *
     * @param req
     * @return
     */
    @PostMapping("/flowable/task/todoList")
    ApiRespPdu<Result<FlowTaskPdu>> todoList(@RequestBody CommonTaskReq req);


    /**
     * 获取已办任务
     * 获取的列表需要和业务系统数据合并
     *
     * @param req
     * @return
     */
    @PostMapping("/flowable/task/finishedList")
    ApiRespPdu<Result<FlowTaskPdu>> finishedList(@RequestBody CommonTaskReq req);

    /**
     * 撤回流程
     *
     * @param revokeTaskReq
     * @return
     */
    @PostMapping("/flowable/task/revokeProcess")
    ApiRespPdu<String> revokeProcess(@RequestBody RevokeTaskReq revokeTaskReq);


    /**
     * 取消申请
     *
     * @param commonTaskReq
     * @return
     */
    @PostMapping("/flowable/task/stopProcess")
    ApiRespPdu<String> stopProcess(@RequestBody CommonTaskReq commonTaskReq);


    /**
     * 流程历史流转记录
     *
     * @param commonTaskReq
     * @return
     */
    @PostMapping("/flowable/task/flowRecord")
    ApiRespPdu<List<FlowTaskPdu>> flowRecord(@RequestBody CommonTaskReq commonTaskReq);

    /**
     * 获取流程变量
     *
     * @param commonTaskReq
     * @return
     */
    @PostMapping("/flowable/task/processVariables")
    ApiRespPdu<Map<String, Object>> processVariables(@RequestBody CommonTaskReq commonTaskReq);


    /**
     * 设置流程变量
     *
     * @param commonTaskReq
     * @return
     */
    @PostMapping("/flowable/task/setProcessVariables")
    ApiRespPdu<String> setProcessVariables(@RequestBody CommonTaskReq commonTaskReq);

    /**
     * 审批任务
     *
     * @param completeTaskReq
     * @return
     */
    @PostMapping("/flowable/task/complete")
    ApiRespPdu<String> complete(@RequestBody CompleteTaskReq completeTaskReq);

    /**
     * 驳回任务
     *
     * @param rejectTaskReq
     * @return
     */
    @PostMapping("/flowable/task/reject")
    ApiRespPdu<String> reject(@RequestBody RejectTaskReq rejectTaskReq);

    /**
     * 退回任务
     *
     * @param deleteTaskReq
     * @return
     */
    @PostMapping("/flowable/task/return")
    ApiRespPdu<String> taskReturn(@RequestBody ReturnTaskReq deleteTaskReq);

    /**
     * 删除任务
     *
     * @param deleteTaskReq
     * @return
     */
    @PostMapping("/flowable/task/delete")
    ApiRespPdu<String> delete(@RequestBody DeleteTaskReq deleteTaskReq);

    /**
     * 认领/签收任务
     *
     * @param flowTaskPdu
     * @return
     */
    @PostMapping("/flowable/task/claim")
    ApiRespPdu<String> claim(@RequestBody FlowTaskVoPdu flowTaskPdu);

    /**
     * 取消认领/签收任务
     *
     * @param flowTaskPdu
     * @return
     */
    @PostMapping("/flowable/task/unClaim")
    ApiRespPdu<String> unClaim(@RequestBody FlowTaskVoPdu flowTaskPdu);

    /**
     * 委派任务
     *
     * @param delegateTaskReq
     * @return
     */
    @PostMapping("/flowable/task/delegate")
    ApiRespPdu<String> delegateTask(@RequestBody DelegateTaskReq delegateTaskReq);

    /**
     * 转办任务
     *
     * @param turnTaskReq
     * @return
     */
    @PostMapping("/flowable/task/assign")
    ApiRespPdu<String> assignTask(@RequestBody TurnTaskReq turnTaskReq);


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


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


    /**
     * 获取下一节点
     *
     * @param commonTaskReq
     * @return
     */
    @PostMapping("/flowable/task/nextFlowNode")
    ApiRespPdu<FlowNextPdu> getNextFlowNode(@RequestBody CommonTaskReq commonTaskReq);


}

