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.FlowProcDefPdu;
import com.mortals.xhx.feign.IFeign;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

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

/**
 * 工作流流程定义
 */
@FeignClient(name = "${application.register.service-name:government-workflow}")
public interface IApiFlowDefinitionFeign extends IFeign {

    /**
     * 获取列表
     *
     * @param userId
     * @param pageInfo
     * @return
     */
    @PostMapping("/flowable/def/list")
    ApiRespPdu<Result<FlowProcDefPdu>> list(@RequestParam(value = "userId") String userId,
                                            @RequestParam(value = "tenantId") String tenantId,
                                            @RequestBody PageInfo pageInfo);

    /**
     * 保存流程设计器内的xml文件
     *
     * @param name
     * @param category
     * @param bpmnXml
     * @return
     */
    @PostMapping("/flowable/def/save")
    ApiRespPdu<String> save(@RequestParam(required = false) String name,
                            @RequestParam(required = false) String category,
                            @RequestParam(required = false) String bpmnXml,
                            @RequestParam(required = false) String tenantId);

    /**
     * 启动流程
     *
     * @param procDefId 部署的流程 Id，来自 ACT_RE_PROCDEF
     * @param userId    业务发起人
     * @param dataKey   业务数据 Key，业务键，一般为表单数据的 ID，仅作为表单数据与流程实例关联的依据
     * @param variables 变量集合,json对象
     * @return
     * @throws AppException
     */
    @PostMapping("/flowable/def/start")
    ApiRespPdu<String> start(@RequestParam(value = "procDefId") String procDefId,
                             @RequestParam(value = "tenantId") String tenantId,
                             @RequestParam(value = "userId") String userId,
                             @RequestParam(value = "dataKey") String dataKey,
                             @RequestBody Map<String, Object> variables);

    /**
     * 激活或挂起流程定义
     *
     * @param state    状态"1:激活,2:挂起"
     * @param deployId 流程部署ID
     * @return
     */
    @PostMapping(value = "/flowable/def/updateState")
    ApiRespPdu<String> updateState(@RequestParam Integer state,
                                   @RequestParam String deployId,
                                   @RequestParam String tenantId);

    /**
     * 删除流程
     *
     * @param deployId 流程部署ID
     * @return
     */
    @PostMapping(value = "/flowable/def/delete")
    ApiRespPdu<String> delete(@RequestParam String deployId);

    /**
     * 读取xml文件
     *
     * @param deployId 流程定义id
     */
    @PostMapping("/flowable/def/readXml")
    ApiRespPdu<String> readXml(@RequestParam(value = "deployId") String deployId);


    /**
     * 根据流程定义 ID 获取流程图 返回BASE64图片
     *
     * @param deployId 流程定义id
     * @return base64图片数据
     * @throws AppException
     */
    @PostMapping("/flowable/def/readImage")
    ApiRespPdu<String> readImage(@RequestParam("deployId") String deployId);


}

