From d6f774dae0a575181b228c680cfc9b0b57b90c7f Mon Sep 17 00:00:00 2001 From: Mohammad Arshad Date: Thu, 15 Aug 2024 07:38:04 +0530 Subject: [PATCH] [Improvement][Seatunnel-web] Execute job REST API should be of type POST, not GET (#183) --- .../seatunnel/app/controller/JobExecutorController.java | 5 +++-- seatunnel-ui/src/service/sync-task-definition/index.ts | 2 +- .../app/controller/JobExecutorControllerWrapper.java | 5 ++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/seatunnel-server/seatunnel-app/src/main/java/org/apache/seatunnel/app/controller/JobExecutorController.java b/seatunnel-server/seatunnel-app/src/main/java/org/apache/seatunnel/app/controller/JobExecutorController.java index 1a41e15b6..ee7773d1f 100644 --- a/seatunnel-server/seatunnel-app/src/main/java/org/apache/seatunnel/app/controller/JobExecutorController.java +++ b/seatunnel-server/seatunnel-app/src/main/java/org/apache/seatunnel/app/controller/JobExecutorController.java @@ -25,6 +25,7 @@ import org.apache.seatunnel.server.common.SeatunnelException; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestAttribute; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -46,8 +47,8 @@ public class JobExecutorController { @Resource IJobExecutorService jobExecutorService; @Resource private IJobInstanceService jobInstanceService; - @GetMapping("/execute") - @ApiOperation(value = "Execute synchronization tasks", httpMethod = "GET") + @PostMapping("/execute") + @ApiOperation(value = "Execute synchronization tasks", httpMethod = "POST") public Result jobExecutor( @ApiParam(value = "userId", required = true) @RequestAttribute("userId") Integer userId, @ApiParam(value = "jobDefineId", required = true) @RequestParam("jobDefineId") diff --git a/seatunnel-ui/src/service/sync-task-definition/index.ts b/seatunnel-ui/src/service/sync-task-definition/index.ts index 3abcc37aa..74bfc8e39 100644 --- a/seatunnel-ui/src/service/sync-task-definition/index.ts +++ b/seatunnel-ui/src/service/sync-task-definition/index.ts @@ -317,7 +317,7 @@ export function sqlModelInfo(taskId: string, pluginId: string, data: any): any { export function executeJob(jobDefineId: number): any { return axios({ url: `/job/executor/execute?jobDefineId=${jobDefineId}`, - method: 'get', + method: 'post', headers: { 'Content-Type': 'application/json;charset=UTF-8' }, diff --git a/seatunnel-web-it/src/test/java/org/apache/seatunnel/app/controller/JobExecutorControllerWrapper.java b/seatunnel-web-it/src/test/java/org/apache/seatunnel/app/controller/JobExecutorControllerWrapper.java index 760d0831d..af23fce53 100644 --- a/seatunnel-web-it/src/test/java/org/apache/seatunnel/app/controller/JobExecutorControllerWrapper.java +++ b/seatunnel-web-it/src/test/java/org/apache/seatunnel/app/controller/JobExecutorControllerWrapper.java @@ -26,7 +26,10 @@ public class JobExecutorControllerWrapper extends SeatunnelWebTestingBase { public Result jobExecutor(Long jobDefineId) { String response = - sendRequest(urlWithParam("job/executor/execute?jobDefineId=" + jobDefineId)); + sendRequest( + urlWithParam("job/executor/execute?jobDefineId=" + jobDefineId), + "{}", + "POST"); return JSONTestUtils.parseObject(response, new TypeReference>() {}); }