feat: OpenAPI 添加工作流实例重试功能

This commit is contained in:
Echo009 2021-02-18 19:41:23 +08:00
parent 9748190a8a
commit 783ea4f67f
4 changed files with 37 additions and 3 deletions

View File

@ -399,6 +399,20 @@ public class OhMyClient {
return JSONObject.parseObject(post, VOID_RESULT_TYPE); 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 * Query detail about a workflow instance
* @param wfInstanceId workflow instanceId * @param wfInstanceId workflow instanceId

View File

@ -94,6 +94,11 @@ class TestWorkflow extends ClientInitializer {
System.out.println(ohMyClient.stopWorkflowInstance(149962433421639744L)); System.out.println(ohMyClient.stopWorkflowInstance(149962433421639744L));
} }
@Test
public void testRetryWorkflowInstance() {
System.out.println(ohMyClient.retryWorkflowInstance(149962433421639744L));
}
@Test @Test
public void testFetchWfInstanceInfo() throws Exception { public void testFetchWfInstanceInfo() throws Exception {
System.out.println(ohMyClient.fetchWorkflowInstanceInfo(149962433421639744L)); System.out.println(ohMyClient.fetchWorkflowInstanceInfo(149962433421639744L));

View File

@ -13,6 +13,7 @@ public class OpenAPIConstant {
public static final String ASSERT = "/assert"; public static final String ASSERT = "/assert";
/* ************* JOB 区 ************* */ /* ************* JOB 区 ************* */
public static final String SAVE_JOB = "/saveJob"; public static final String SAVE_JOB = "/saveJob";
public static final String FETCH_JOB = "/fetchJob"; public static final String FETCH_JOB = "/fetchJob";
public static final String FETCH_ALL_JOB = "/fetchAllJob"; public static final String FETCH_ALL_JOB = "/fetchAllJob";
@ -23,6 +24,7 @@ public class OpenAPIConstant {
public static final String RUN_JOB = "/runJob"; public static final String RUN_JOB = "/runJob";
/* ************* Instance 区 ************* */ /* ************* Instance 区 ************* */
public static final String STOP_INSTANCE = "/stopInstance"; public static final String STOP_INSTANCE = "/stopInstance";
public static final String CANCEL_INSTANCE = "/cancelInstance"; public static final String CANCEL_INSTANCE = "/cancelInstance";
public static final String RETRY_INSTANCE = "/retryInstance"; public static final String RETRY_INSTANCE = "/retryInstance";
@ -31,6 +33,7 @@ public class OpenAPIConstant {
public static final String QUERY_INSTANCE = "/queryInstance"; public static final String QUERY_INSTANCE = "/queryInstance";
/* ************* Workflow 区 ************* */ /* ************* Workflow 区 ************* */
public static final String SAVE_WORKFLOW = "/saveWorkflow"; public static final String SAVE_WORKFLOW = "/saveWorkflow";
public static final String FETCH_WORKFLOW = "/fetchWorkflow"; public static final String FETCH_WORKFLOW = "/fetchWorkflow";
public static final String DISABLE_WORKFLOW = "/disableWorkflow"; public static final String DISABLE_WORKFLOW = "/disableWorkflow";
@ -39,6 +42,8 @@ public class OpenAPIConstant {
public static final String RUN_WORKFLOW = "/runWorkflow"; public static final String RUN_WORKFLOW = "/runWorkflow";
/* ************* WorkflowInstance 区 ************* */ /* ************* WorkflowInstance 区 ************* */
public static final String STOP_WORKFLOW_INSTANCE = "/stopWfInstance"; 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"; public static final String FETCH_WORKFLOW_INSTANCE_INFO = "/fetchWfInstanceInfo";
} }

View File

@ -16,6 +16,7 @@ import com.github.kfcfans.powerjob.common.response.*;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.text.ParseException;
import java.util.List; import java.util.List;
/** /**
@ -50,7 +51,7 @@ public class OpenAPIController {
/* ************* Job 区 ************* */ /* ************* Job 区 ************* */
@PostMapping(OpenAPIConstant.SAVE_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) { if (request.getId() != null) {
checkJobIdValid(request.getId(), request.getAppId()); checkJobIdValid(request.getId(), request.getAppId());
} }
@ -86,7 +87,7 @@ public class OpenAPIController {
return ResultDTO.success(null); return ResultDTO.success(null);
} }
@PostMapping(OpenAPIConstant.ENABLE_JOB) @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); checkJobIdValid(jobId, appId);
jobService.enableJob(jobId); jobService.enableJob(jobId);
return ResultDTO.success(null); return ResultDTO.success(null);
@ -138,8 +139,9 @@ public class OpenAPIController {
} }
/* ************* Workflow 区 ************* */ /* ************* Workflow 区 ************* */
@PostMapping(OpenAPIConstant.SAVE_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)); return ResultDTO.success(workflowService.saveWorkflow(request));
} }
@ -170,11 +172,19 @@ public class OpenAPIController {
} }
/* ************* Workflow Instance 区 ************* */ /* ************* Workflow Instance 区 ************* */
@PostMapping(OpenAPIConstant.STOP_WORKFLOW_INSTANCE) @PostMapping(OpenAPIConstant.STOP_WORKFLOW_INSTANCE)
public ResultDTO<Void> stopWorkflowInstance(Long wfInstanceId, Long appId) { public ResultDTO<Void> stopWorkflowInstance(Long wfInstanceId, Long appId) {
workflowInstanceService.stopWorkflowInstance(wfInstanceId, appId); workflowInstanceService.stopWorkflowInstance(wfInstanceId, appId);
return ResultDTO.success(null); 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) @PostMapping(OpenAPIConstant.FETCH_WORKFLOW_INSTANCE_INFO)
public ResultDTO<WorkflowInstanceInfoDTO> fetchWorkflowInstanceInfo(Long wfInstanceId, Long appId) { public ResultDTO<WorkflowInstanceInfoDTO> fetchWorkflowInstanceInfo(Long wfInstanceId, Long appId) {
return ResultDTO.success(workflowInstanceService.fetchWorkflowInstanceInfo(wfInstanceId, appId)); return ResultDTO.success(workflowInstanceService.fetchWorkflowInstanceInfo(wfInstanceId, appId));