package cn.axzo.workflow.client.feign.bpmn;

import cn.axzo.workflow.client.annotation.WorkflowEngineFeignClient;
import cn.axzo.workflow.common.annotation.Manageable;
import cn.azxo.framework.common.model.CommonResponse;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

//@FeignClient(name = "workflow-engine", url = "${axzo.service.workflow-engine:http://workflow-engine:8080}", configuration = CommonFeignConfiguration.class)
@WorkflowEngineFeignClient
public interface ProcessJobApi {

    /**
     * 将死信队列中的任务转移到正常 JOB 队列中
     * <p>
     * 入参是二选一：当只有 jobId 时，仅将指定的 JOB 转移到正常的队列中；
     * 而传入的是具体的实例 ID，那么会将这个流程下的所有在死信队列中的任务都转移到正常的队列中
     *
     * @param jobId      具体的 JOB ID
     * @param procInstId 具体的实例 ID
     * @return
     */
    @GetMapping("/api/process/job/dead-letter/resume")
    @Manageable
    CommonResponse<Void> executeDeadLetterJobAction(@RequestParam(required = false) String jobId,
                                                    @RequestParam(required = false) String procInstId);

    /**
     * 查询死信消息数据
     * @param procInstId 流程实例id
     * @return
     */
    @GetMapping("/dead-letter/exception/stacktrace")
    @Manageable
    String getDeadLetterJobExceptionStacktrace(@RequestParam String procInstId);

    /**
     * 查询死信消息数据
     * @param jobId 死信job的id
     * @return
     */
    @GetMapping("/dead-letter/exception/stacktrace/byId")
    @Manageable
    String getDeadLetterJobExceptionStacktraceByJobId(@RequestParam String jobId);
}
