package com.mortals.xhx.feign.flowable;

import com.mortals.xhx.common.pdu.api.ApiRespPdu;
import com.mortals.xhx.common.pdu.flow.FlowViewerPdu;
import com.mortals.xhx.feign.IFeign;
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:government-workflow}")
public interface IApiFlowInstanceFeign extends IFeign {

    /**
     * 根据流程定义id启动流程实例
     *
     * @param deployId  流程定义id
     * @param variables 变量集合,json对象
     * @return
     */
    @PostMapping("/flowable/instance/startById")
    ApiRespPdu<String> startById(@RequestParam(value = "deployId") String deployId,
                                 @RequestBody Map<String, Object> variables);


    /**
     * 激活或挂起流程实例
     *
     * @param state      1:激活,2:挂起
     * @param instanceId 流程实例ID
     * @return
     */
    @PostMapping("/flowable/instance/updateState")
    ApiRespPdu<String> updateState(@RequestParam Integer state,
                                   @RequestParam String instanceId);


    /**
     * 中止流程
     *
     * @param processId 流程ID
     * @return
     */
    @RequestMapping("/flowable/instance/stopProcess")
    ApiRespPdu<String> stopProcess(@RequestParam(value = "processId") String processId);

    /**
     * 删除流程实例
     *
     * @param instanceId   流程实例ID
     * @param deleteReason 删除原因
     * @return
     */
    @PostMapping("/flowable/instance/deleteProcess")
    ApiRespPdu<String> deleteProcess(@RequestParam String instanceId,
                                     @RequestParam String deleteReason);


    /**
     *
     * @param procInsId
     * @return
     */
    @PostMapping("/flowable/instance/getFlowViewer")
    ApiRespPdu<List<FlowViewerPdu>> getFlowViewer(String procInsId);

}

