mirror of
https://github.com/PowerJob/PowerJob.git
synced 2025-07-17 00:00:04 +08:00
feat: OpenAPI 添加工作流实例重试功能
This commit is contained in:
parent
9748190a8a
commit
783ea4f67f
@ -399,6 +399,20 @@ public class OhMyClient {
|
||||
return JSONObject.parseObject(post, VOID_RESULT_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retry one workflow instance
|
||||
* @param wfInstanceId workflow instanceId
|
||||
* @return Standard return object
|
||||
*/
|
||||
public ResultDTO<Void> retryWorkflowInstance(Long wfInstanceId) {
|
||||
RequestBody body = new FormBody.Builder()
|
||||
.add("wfInstanceId", wfInstanceId.toString())
|
||||
.add("appId", appId.toString())
|
||||
.build();
|
||||
String post = postHA(OpenAPIConstant.RETRY_WORKFLOW_INSTANCE, body);
|
||||
return JSONObject.parseObject(post, VOID_RESULT_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query detail about a workflow instance
|
||||
* @param wfInstanceId workflow instanceId
|
||||
|
@ -94,6 +94,11 @@ class TestWorkflow extends ClientInitializer {
|
||||
System.out.println(ohMyClient.stopWorkflowInstance(149962433421639744L));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRetryWorkflowInstance() {
|
||||
System.out.println(ohMyClient.retryWorkflowInstance(149962433421639744L));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFetchWfInstanceInfo() throws Exception {
|
||||
System.out.println(ohMyClient.fetchWorkflowInstanceInfo(149962433421639744L));
|
||||
|
@ -13,6 +13,7 @@ public class OpenAPIConstant {
|
||||
public static final String ASSERT = "/assert";
|
||||
|
||||
/* ************* JOB 区 ************* */
|
||||
|
||||
public static final String SAVE_JOB = "/saveJob";
|
||||
public static final String FETCH_JOB = "/fetchJob";
|
||||
public static final String FETCH_ALL_JOB = "/fetchAllJob";
|
||||
@ -23,6 +24,7 @@ public class OpenAPIConstant {
|
||||
public static final String RUN_JOB = "/runJob";
|
||||
|
||||
/* ************* Instance 区 ************* */
|
||||
|
||||
public static final String STOP_INSTANCE = "/stopInstance";
|
||||
public static final String CANCEL_INSTANCE = "/cancelInstance";
|
||||
public static final String RETRY_INSTANCE = "/retryInstance";
|
||||
@ -31,6 +33,7 @@ public class OpenAPIConstant {
|
||||
public static final String QUERY_INSTANCE = "/queryInstance";
|
||||
|
||||
/* ************* Workflow 区 ************* */
|
||||
|
||||
public static final String SAVE_WORKFLOW = "/saveWorkflow";
|
||||
public static final String FETCH_WORKFLOW = "/fetchWorkflow";
|
||||
public static final String DISABLE_WORKFLOW = "/disableWorkflow";
|
||||
@ -39,6 +42,8 @@ public class OpenAPIConstant {
|
||||
public static final String RUN_WORKFLOW = "/runWorkflow";
|
||||
|
||||
/* ************* WorkflowInstance 区 ************* */
|
||||
|
||||
public static final String STOP_WORKFLOW_INSTANCE = "/stopWfInstance";
|
||||
public static final String RETRY_WORKFLOW_INSTANCE = "/retryWfInstance";
|
||||
public static final String FETCH_WORKFLOW_INSTANCE_INFO = "/fetchWfInstanceInfo";
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import com.github.kfcfans.powerjob.common.response.*;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.text.ParseException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -50,7 +51,7 @@ public class OpenAPIController {
|
||||
|
||||
/* ************* Job 区 ************* */
|
||||
@PostMapping(OpenAPIConstant.SAVE_JOB)
|
||||
public ResultDTO<Long> saveJob(@RequestBody SaveJobInfoRequest request) throws Exception {
|
||||
public ResultDTO<Long> saveJob(@RequestBody SaveJobInfoRequest request) throws ParseException {
|
||||
if (request.getId() != null) {
|
||||
checkJobIdValid(request.getId(), request.getAppId());
|
||||
}
|
||||
@ -86,7 +87,7 @@ public class OpenAPIController {
|
||||
return ResultDTO.success(null);
|
||||
}
|
||||
@PostMapping(OpenAPIConstant.ENABLE_JOB)
|
||||
public ResultDTO<Void> enableJob(Long jobId, Long appId) throws Exception {
|
||||
public ResultDTO<Void> enableJob(Long jobId, Long appId) throws ParseException {
|
||||
checkJobIdValid(jobId, appId);
|
||||
jobService.enableJob(jobId);
|
||||
return ResultDTO.success(null);
|
||||
@ -138,8 +139,9 @@ public class OpenAPIController {
|
||||
}
|
||||
|
||||
/* ************* Workflow 区 ************* */
|
||||
|
||||
@PostMapping(OpenAPIConstant.SAVE_WORKFLOW)
|
||||
public ResultDTO<Long> saveWorkflow(@RequestBody SaveWorkflowRequest request) throws Exception {
|
||||
public ResultDTO<Long> saveWorkflow(@RequestBody SaveWorkflowRequest request) throws ParseException {
|
||||
return ResultDTO.success(workflowService.saveWorkflow(request));
|
||||
}
|
||||
|
||||
@ -170,11 +172,19 @@ public class OpenAPIController {
|
||||
}
|
||||
|
||||
/* ************* Workflow Instance 区 ************* */
|
||||
|
||||
@PostMapping(OpenAPIConstant.STOP_WORKFLOW_INSTANCE)
|
||||
public ResultDTO<Void> stopWorkflowInstance(Long wfInstanceId, Long appId) {
|
||||
workflowInstanceService.stopWorkflowInstance(wfInstanceId, appId);
|
||||
return ResultDTO.success(null);
|
||||
}
|
||||
|
||||
@PostMapping(OpenAPIConstant.RETRY_WORKFLOW_INSTANCE)
|
||||
public ResultDTO<Void> retryWorkflowInstance(Long wfInstanceId, Long appId) {
|
||||
workflowInstanceService.retryWorkflowInstance(wfInstanceId, appId);
|
||||
return ResultDTO.success(null);
|
||||
}
|
||||
|
||||
@PostMapping(OpenAPIConstant.FETCH_WORKFLOW_INSTANCE_INFO)
|
||||
public ResultDTO<WorkflowInstanceInfoDTO> fetchWorkflowInstanceInfo(Long wfInstanceId, Long appId) {
|
||||
return ResultDTO.success(workflowInstanceService.fetchWorkflowInstanceInfo(wfInstanceId, appId));
|
||||
|
Loading…
x
Reference in New Issue
Block a user