You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by GitBox <gi...@apache.org> on 2022/07/04 01:03:54 UTC

[GitHub] [incubator-seatunnel] CalvinKirs commented on a diff in pull request #2112: [seatunnel-1947][seatunnel-server] init & add interface for script/user

CalvinKirs commented on code in PR #2112:
URL: https://github.com/apache/incubator-seatunnel/pull/2112#discussion_r912563663


##########
seatunnel-server/seatunnel-app/src/main/java/org/apache/seatunnel/app/controller/ScriptController.java:
##########
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.app.controller;
+
+import org.apache.seatunnel.app.common.Result;
+import org.apache.seatunnel.app.domain.request.script.AddEmptyScriptReq;
+import org.apache.seatunnel.app.domain.request.script.ScriptListReq;
+import org.apache.seatunnel.app.domain.request.script.UpdateScriptContentReq;
+import org.apache.seatunnel.app.domain.request.script.UpdateScriptParamReq;
+import org.apache.seatunnel.app.domain.response.script.ScriptParamRes;
+import org.apache.seatunnel.app.domain.response.script.ScriptSimpleInfoRes;
+import org.apache.seatunnel.app.service.IScriptService;
+
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import javax.validation.constraints.NotNull;
+
+import java.util.List;
+
+@RequestMapping("/api/v1/script")
+@RestController
+public class ScriptController {
+    @Resource
+    private IScriptService iScriptService;
+
+    @PostMapping("/addEmptyScript")
+    @ApiOperation(value = "add an empty script", httpMethod = "POST")
+    public Result<Void> addEmptyScript(@RequestBody @NotNull AddEmptyScriptReq addEmptyScriptReq) {
+        iScriptService.addEmptyScript(addEmptyScriptReq);
+        return Result.success();
+    }
+
+    @PutMapping("/updateScriptContent")
+    @ApiOperation(value = "update script", httpMethod = "POST")
+    public Result<Void> updateScriptContent(@RequestBody @NotNull UpdateScriptContentReq updateScriptContentReq) {
+        iScriptService.updateScriptContent(updateScriptContentReq);
+        return Result.success();
+    }
+
+    @DeleteMapping("/delete")
+    @ApiOperation(value = "delete script", httpMethod = "POST")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "script id", dataType = "Integer"),
+    })
+    public Result<Void> delete(@RequestParam @NotNull Integer id) {
+        iScriptService.delete(id);
+        return Result.success();
+    }
+
+    @PostMapping("/list")
+    @ApiOperation(value = "script list", httpMethod = "POST")
+    public Result<List<ScriptSimpleInfoRes>> list(@RequestBody @NotNull ScriptListReq scriptListReq) {
+        return Result.success(iScriptService.list(scriptListReq));

Review Comment:
   We use the standard Restful style, so the operation methods of add and delete will not need to be reflected in the Url



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org