package com.mortals.xhx.feign.flowable;

import com.mortals.xhx.common.pdu.api.ApiRespPdu;
import com.mortals.xhx.common.pdu.flow.FlowTaskPdu;
import com.mortals.xhx.common.pdu.flow.FlowTaskVoPdu;
import com.mortals.xhx.common.pdu.flow.FlowViewerPdu;
import com.mortals.xhx.feign.IFeign;
import com.mortals.xhx.flowable.processinstance.ProcessCommonReq;
import com.mortals.xhx.flowable.processinstance.ProcessDeleteReq;
import com.mortals.xhx.flowable.processinstance.ProcessStopReq;
import com.mortals.xhx.flowable.processinstance.ProcessUpdateStateReq;
import com.mortals.xhx.flowable.runtime.StartProcessInstanceReq;
import feign.QueryMap;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

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 IApiFlowInstanceFeign extends IFeign {


    /**
     * 根据流程key 启动流程实例
     *
     * @param startProcessInstanceReq
     * @return
     */
    @PostMapping("/flowable/instance/startByKey")
    ApiRespPdu<String> startProcessInstanceByKey(@RequestBody StartProcessInstanceReq startProcessInstanceReq);


    /**
     * 激活或挂起流程实例
     * 1:激活,2:挂起
     *
     * @param processUpdateStateReq
     * @return
     */
    @PostMapping("/flowable/instance/updateState")
    ApiRespPdu<String> updateState(@RequestBody ProcessUpdateStateReq processUpdateStateReq);


    /**
     * 中止流程
     *
     * @param processStopReq 流程
     * @return
     */
    @RequestMapping("/flowable/instance/stopProcess")
    ApiRespPdu<String> stopProcess(@RequestBody ProcessStopReq processStopReq);

    /**
     * 删除流程实例（当前与历史数据都会删除）
     *
     * @param processDeleteReq 流程实例ID
     * @return
     */
    @PostMapping("/flowable/instance/deleteProcess")
    ApiRespPdu<String> deleteProcess(@RequestBody ProcessDeleteReq processDeleteReq);


    /**
     * 获取流程所有节点
     *
     * @param processCommonReq
     * @return
     */
    @PostMapping("/flowable/instance/getFlowViewer")
    ApiRespPdu<List<FlowViewerPdu>> getFlowViewer(@RequestBody ProcessCommonReq processCommonReq);


    /**
     * 获取流程当前运行节点图
     *
     * @param processCommonReq
     * @return
     */
    @PostMapping("/flowable/instance/getFlowImage")
    ApiRespPdu<String> getFlowImage(@RequestBody ProcessCommonReq processCommonReq);

    /**
     * 获取流程当前所有任务el图
     *
     * @param params
     * @return
     */
    @PostMapping("/flowable/instance/getAllProcessInstanceEl")
    ApiRespPdu<List<FlowTaskVoPdu>> getAllProcessInstanceEl(@RequestBody StartProcessInstanceReq params);

}