Unverified Commit be13e0c0 authored by aiwenmo's avatar aiwenmo Committed by GitHub

[Fix-1615] [api] Fix submit task error but return succeed when using dolphinscheduler (#2469)

parent 55252345
......@@ -24,6 +24,7 @@ import org.dinky.data.dto.TaskDTO;
import org.dinky.data.enums.BusinessType;
import org.dinky.data.enums.Status;
import org.dinky.data.exception.NotSupportExplainExcepition;
import org.dinky.data.model.ID;
import org.dinky.data.model.JobInstance;
import org.dinky.data.result.Result;
import org.dinky.data.result.SqlExplainResult;
......@@ -64,11 +65,25 @@ public class APIController {
private final TaskService taskService;
private final JobInstanceService jobInstanceService;
// Interface compatible with DolphinScheduler
@GetMapping("/submitTask")
@ApiOperation("Submit Task")
public Result<JobResult> submitTask(@RequestParam Integer id) throws Exception {
taskService.initTenantByTaskId(id);
JobResult jobResult = taskService.submitTask(id, null);
if (jobResult.isSuccess()) {
return Result.succeed(jobResult, Status.EXECUTE_SUCCESS);
} else {
return Result.failed(jobResult, jobResult.getError());
}
}
@PostMapping("/submitTask")
@ApiOperation("Submit Task")
// @Log(title = "Submit Task", businessType = BusinessType.SUBMIT)
public Result<JobResult> submitTask(@RequestBody TaskDTO taskDTO) throws Exception {
JobResult jobResult = taskService.submitTask(taskDTO.getId(), null);
public Result<JobResult> submitTask(@RequestBody ID id) throws Exception {
taskService.initTenantByTaskId(id.getId());
JobResult jobResult = taskService.submitTask(id.getId(), null);
if (jobResult.isSuccess()) {
return Result.succeed(jobResult, Status.EXECUTE_SUCCESS);
} else {
......
......@@ -256,8 +256,6 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
@Override
@ProcessStep(type = ProcessStepType.SUBMIT_TASK)
public JobResult submitTask(Integer id, String savePointPath) throws Exception {
initTenantByTaskId(id);
TaskDTO taskDTO = this.getTaskInfoById(id);
if (StringUtils.isNotBlank(savePointPath)) {
......
......@@ -128,7 +128,7 @@ public class JobResult {
this.jobConfig = jobConfig;
this.jobManagerAddress = jobManagerAddress;
this.status = status;
this.success = (status == (Job.JobStatus.SUCCESS)) ? true : false;
this.success = status == (Job.JobStatus.SUCCESS);
this.statement = statement;
this.jobId = jobId;
this.error = error;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment