You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2022/09/19 02:44:12 UTC

[GitHub] [dolphinscheduler] ruanwenjun commented on a diff in pull request #11912: [Feature][API] New restful API for workflow and schedule

ruanwenjun commented on code in PR #11912:
URL: https://github.com/apache/dolphinscheduler/pull/11912#discussion_r973828469


##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/schedule/ScheduleCreateRequest.java:
##########
@@ -0,0 +1,120 @@
+/*
+ * 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.dolphinscheduler.api.dto.schedule;
+
+import static org.apache.dolphinscheduler.common.utils.DateUtils.stringToDate;
+
+import org.apache.dolphinscheduler.common.enums.FailureStrategy;
+import org.apache.dolphinscheduler.common.enums.Priority;
+import org.apache.dolphinscheduler.common.enums.ReleaseState;
+import org.apache.dolphinscheduler.common.enums.WarningType;
+import org.apache.dolphinscheduler.dao.entity.Schedule;
+
+import java.util.Date;
+
+import lombok.Data;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * schedule create request
+ */
+@Data
+public class ScheduleCreateRequest {
+
+    @ApiModelProperty(example = "1234567890123", required = true)
+    private long processDefinitionCode;
+
+    @ApiModelProperty(example = "schedule timezone", required = true)
+    private String crontab;
+
+    @ApiModelProperty(example = "2021-01-01 10:00:00", required = true)
+    private String startTime;
+
+    @ApiModelProperty(example = "2022-01-01 12:00:00", required = true)
+    private String endTime;
+
+    @ApiModelProperty(example = "Asia/Shanghai", required = true)
+    private String timezoneId;
+
+    @ApiModelProperty(allowableValues = "CONTINUE / END", example = "CONTINUE", notes = "default CONTINUE if value not provide.")
+    private String failureStrategy;
+
+    @ApiModelProperty(allowableValues = "ONLINE / OFFLINE", example = "OFFLINE", notes = "default OFFLINE if value not provide.")
+    private String releaseState;
+
+    @ApiModelProperty(allowableValues = "NONE / SUCCESS / FAILURE / ALL", example = "SUCCESS", notes = "default NONE if value not provide.")
+    private String warningType;
+
+    @ApiModelProperty(example = "2", notes = "default 0 if value not provide.")
+    private int warningGroupId;
+
+    @ApiModelProperty(allowableValues = "HIGHEST / HIGH / MEDIUM / LOW / LOWEST", example = "MEDIUM", notes = "default MEDIUM if value not provide.")
+    private String processInstancePriority;
+
+    @ApiModelProperty(example = "worker-group-name")
+    private String workerGroup;
+
+    @ApiModelProperty(example = "environment-code")
+    private long environmentCode;
+
+    public String getScheduleParam() {

Review Comment:
   It's better to create a pojo named ScheduleParam with this 4 fields.



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/ResourceResponse.java:
##########
@@ -0,0 +1,39 @@
+/*
+ * 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.dolphinscheduler.api.dto;
+
+import org.apache.dolphinscheduler.api.enums.Status;
+import org.apache.dolphinscheduler.api.utils.Result;
+
+import lombok.Data;
+
+/**
+ * workflow response
+ */
+@Data
+public class ResourceResponse<T> extends Result<T> {

Review Comment:
   It seems this pojo is same with Result.



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/WorkflowV2Controller.java:
##########
@@ -0,0 +1,168 @@
+/*
+ * 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.dolphinscheduler.api.controller;
+
+import static org.apache.dolphinscheduler.api.enums.Status.CREATE_PROCESS_DEFINITION_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.DELETE_PROCESS_DEFINE_BY_CODE_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_PROCESS_DEFINITION_LIST;
+import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_PROCESS_DEFINITION_ERROR;
+
+import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
+import org.apache.dolphinscheduler.api.dto.PageResourceResponse;
+import org.apache.dolphinscheduler.api.dto.ResourceResponse;
+import org.apache.dolphinscheduler.api.dto.workflow.WorkflowCreateRequest;
+import org.apache.dolphinscheduler.api.dto.workflow.WorkflowFilterRequest;
+import org.apache.dolphinscheduler.api.dto.workflow.WorkflowUpdateRequest;
+import org.apache.dolphinscheduler.api.enums.Status;
+import org.apache.dolphinscheduler.api.exceptions.ApiException;
+import org.apache.dolphinscheduler.api.service.ProcessDefinitionService;
+import org.apache.dolphinscheduler.api.utils.PageInfo;
+import org.apache.dolphinscheduler.api.utils.Result;
+import org.apache.dolphinscheduler.common.Constants;
+import org.apache.dolphinscheduler.dao.entity.ProcessDefinition;
+import org.apache.dolphinscheduler.dao.entity.User;
+
+import springfox.documentation.annotations.ApiIgnore;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestAttribute;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+
+/**
+ * workflow controller
+ */
+@Api(tags = "WORKFLOW_TAG")
+@RestController
+@RequestMapping("/v2/workflows")
+public class WorkflowV2Controller extends BaseController {
+
+    @Autowired
+    private ProcessDefinitionService processDefinitionService;
+
+    /**
+     * Create resource workflow
+     *
+     * @param loginUser             login user
+     * @param workflowCreateRequest the new workflow object will be created
+     * @return ResourceResponse object created
+     */
+    @ApiOperation(value = "create", notes = "CREATE_WORKFLOWS_NOTES")
+    @PostMapping(consumes = {"application/json"})
+    @ResponseStatus(HttpStatus.CREATED)
+    @ApiException(CREATE_PROCESS_DEFINITION_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public ResourceResponse createWorkflows(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,

Review Comment:
   ```suggestion
       public Result<ProcessDefinition> createWorkflows(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
   ```



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/WorkflowV2Controller.java:
##########
@@ -0,0 +1,168 @@
+/*
+ * 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.dolphinscheduler.api.controller;
+
+import static org.apache.dolphinscheduler.api.enums.Status.CREATE_PROCESS_DEFINITION_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.DELETE_PROCESS_DEFINE_BY_CODE_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_PROCESS_DEFINITION_LIST;
+import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_PROCESS_DEFINITION_ERROR;
+
+import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
+import org.apache.dolphinscheduler.api.dto.PageResourceResponse;
+import org.apache.dolphinscheduler.api.dto.ResourceResponse;
+import org.apache.dolphinscheduler.api.dto.workflow.WorkflowCreateRequest;
+import org.apache.dolphinscheduler.api.dto.workflow.WorkflowFilterRequest;
+import org.apache.dolphinscheduler.api.dto.workflow.WorkflowUpdateRequest;
+import org.apache.dolphinscheduler.api.enums.Status;
+import org.apache.dolphinscheduler.api.exceptions.ApiException;
+import org.apache.dolphinscheduler.api.service.ProcessDefinitionService;
+import org.apache.dolphinscheduler.api.utils.PageInfo;
+import org.apache.dolphinscheduler.api.utils.Result;
+import org.apache.dolphinscheduler.common.Constants;
+import org.apache.dolphinscheduler.dao.entity.ProcessDefinition;
+import org.apache.dolphinscheduler.dao.entity.User;
+
+import springfox.documentation.annotations.ApiIgnore;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestAttribute;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+
+/**
+ * workflow controller
+ */
+@Api(tags = "WORKFLOW_TAG")
+@RestController
+@RequestMapping("/v2/workflows")
+public class WorkflowV2Controller extends BaseController {
+
+    @Autowired
+    private ProcessDefinitionService processDefinitionService;
+
+    /**
+     * Create resource workflow
+     *
+     * @param loginUser             login user
+     * @param workflowCreateRequest the new workflow object will be created
+     * @return ResourceResponse object created
+     */
+    @ApiOperation(value = "create", notes = "CREATE_WORKFLOWS_NOTES")
+    @PostMapping(consumes = {"application/json"})
+    @ResponseStatus(HttpStatus.CREATED)
+    @ApiException(CREATE_PROCESS_DEFINITION_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public ResourceResponse createWorkflows(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                            @RequestBody WorkflowCreateRequest workflowCreateRequest) {
+        ProcessDefinition processDefinition =
+                processDefinitionService.createProcessDefinitionV2(loginUser, workflowCreateRequest);
+        return new ResourceResponse(processDefinition);
+    }
+
+    /**
+     * Delete workflow by code
+     *
+     * @param loginUser login user
+     * @param code      process definition code
+     * @return Result result object delete
+     */
+    @ApiOperation(value = "delete", notes = "DELETE_WORKFLOWS_NOTES")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "code", value = "WORKFLOW_CODE", dataTypeClass = long.class, example = "123456", required = true)
+    })
+    @DeleteMapping(value = "/{code}")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(DELETE_PROCESS_DEFINE_BY_CODE_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result deleteWorkflows(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                  @PathVariable("code") Long code) {
+        processDefinitionService.deleteProcessDefinitionByCode(loginUser, code);
+        return new Result(Status.SUCCESS);
+    }
+
+    /**
+     * Update resource workflow
+     *
+     * @param loginUser        login user
+     * @param code             workflow resource code you want to update
+     * @param workflowUpdateRequest workflowUpdateRequest
+     * @return ResourceResponse object updated
+     */
+    @ApiOperation(value = "update", notes = "UPDATE_WORKFLOWS_NOTES")
+    @PutMapping(value = "/{code}")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(UPDATE_PROCESS_DEFINITION_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public ResourceResponse updateWorkflows(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                            @PathVariable("code") Long code,
+                                            @RequestBody WorkflowUpdateRequest workflowUpdateRequest) {
+        ProcessDefinition processDefinition =
+                processDefinitionService.updateProcessDefinitionV2(loginUser, code, workflowUpdateRequest);
+        return new ResourceResponse(processDefinition);
+    }
+
+    /**
+     * Get resource workflow
+     *
+     * @param loginUser        login user
+     * @param code             workflow resource code you want to update
+     * @return ResourceResponse object get from condition
+     */
+    @ApiOperation(value = "get", notes = "GET_WORKFLOWS_NOTES")
+    @GetMapping(value = "/{code}")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_PROCESS_DEFINITION_LIST)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public ResourceResponse getWorkflows(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,

Review Comment:
   ```suggestion
       public Result<ProcessDefinition> getWorkflows(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
   ```



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/WorkflowV2Controller.java:
##########
@@ -0,0 +1,168 @@
+/*
+ * 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.dolphinscheduler.api.controller;
+
+import static org.apache.dolphinscheduler.api.enums.Status.CREATE_PROCESS_DEFINITION_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.DELETE_PROCESS_DEFINE_BY_CODE_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_PROCESS_DEFINITION_LIST;
+import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_PROCESS_DEFINITION_ERROR;
+
+import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
+import org.apache.dolphinscheduler.api.dto.PageResourceResponse;
+import org.apache.dolphinscheduler.api.dto.ResourceResponse;
+import org.apache.dolphinscheduler.api.dto.workflow.WorkflowCreateRequest;
+import org.apache.dolphinscheduler.api.dto.workflow.WorkflowFilterRequest;
+import org.apache.dolphinscheduler.api.dto.workflow.WorkflowUpdateRequest;
+import org.apache.dolphinscheduler.api.enums.Status;
+import org.apache.dolphinscheduler.api.exceptions.ApiException;
+import org.apache.dolphinscheduler.api.service.ProcessDefinitionService;
+import org.apache.dolphinscheduler.api.utils.PageInfo;
+import org.apache.dolphinscheduler.api.utils.Result;
+import org.apache.dolphinscheduler.common.Constants;
+import org.apache.dolphinscheduler.dao.entity.ProcessDefinition;
+import org.apache.dolphinscheduler.dao.entity.User;
+
+import springfox.documentation.annotations.ApiIgnore;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestAttribute;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+
+/**
+ * workflow controller
+ */
+@Api(tags = "WORKFLOW_TAG")
+@RestController
+@RequestMapping("/v2/workflows")
+public class WorkflowV2Controller extends BaseController {
+
+    @Autowired
+    private ProcessDefinitionService processDefinitionService;
+
+    /**
+     * Create resource workflow
+     *
+     * @param loginUser             login user
+     * @param workflowCreateRequest the new workflow object will be created
+     * @return ResourceResponse object created
+     */
+    @ApiOperation(value = "create", notes = "CREATE_WORKFLOWS_NOTES")
+    @PostMapping(consumes = {"application/json"})
+    @ResponseStatus(HttpStatus.CREATED)
+    @ApiException(CREATE_PROCESS_DEFINITION_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public ResourceResponse createWorkflows(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                            @RequestBody WorkflowCreateRequest workflowCreateRequest) {
+        ProcessDefinition processDefinition =
+                processDefinitionService.createProcessDefinitionV2(loginUser, workflowCreateRequest);
+        return new ResourceResponse(processDefinition);
+    }
+
+    /**
+     * Delete workflow by code
+     *
+     * @param loginUser login user
+     * @param code      process definition code
+     * @return Result result object delete
+     */
+    @ApiOperation(value = "delete", notes = "DELETE_WORKFLOWS_NOTES")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "code", value = "WORKFLOW_CODE", dataTypeClass = long.class, example = "123456", required = true)
+    })
+    @DeleteMapping(value = "/{code}")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(DELETE_PROCESS_DEFINE_BY_CODE_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result deleteWorkflows(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                  @PathVariable("code") Long code) {
+        processDefinitionService.deleteProcessDefinitionByCode(loginUser, code);
+        return new Result(Status.SUCCESS);
+    }
+
+    /**
+     * Update resource workflow
+     *
+     * @param loginUser        login user
+     * @param code             workflow resource code you want to update
+     * @param workflowUpdateRequest workflowUpdateRequest
+     * @return ResourceResponse object updated
+     */
+    @ApiOperation(value = "update", notes = "UPDATE_WORKFLOWS_NOTES")
+    @PutMapping(value = "/{code}")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(UPDATE_PROCESS_DEFINITION_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public ResourceResponse updateWorkflows(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                            @PathVariable("code") Long code,
+                                            @RequestBody WorkflowUpdateRequest workflowUpdateRequest) {
+        ProcessDefinition processDefinition =
+                processDefinitionService.updateProcessDefinitionV2(loginUser, code, workflowUpdateRequest);
+        return new ResourceResponse(processDefinition);
+    }
+
+    /**
+     * Get resource workflow
+     *
+     * @param loginUser        login user
+     * @param code             workflow resource code you want to update
+     * @return ResourceResponse object get from condition
+     */
+    @ApiOperation(value = "get", notes = "GET_WORKFLOWS_NOTES")
+    @GetMapping(value = "/{code}")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_PROCESS_DEFINITION_LIST)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public ResourceResponse getWorkflows(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                         @PathVariable("code") Long code) {
+        ProcessDefinition processDefinition = processDefinitionService.getProcessDefinition(loginUser, code);
+        return new ResourceResponse(processDefinition);
+    }
+
+    /**
+     * Get resource workflows according to query parameter
+     *
+     * @param loginUser        login user
+     * @param workflowFilterRequest workflowFilterRequest
+     * @return PageResourceResponse from condition
+     */
+    @ApiOperation(value = "get", notes = "FILTER_WORKFLOWS_NOTES")
+    @GetMapping(consumes = {"application/json"})
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_PROCESS_DEFINITION_LIST)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public PageResourceResponse filterWorkflows(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,

Review Comment:
   ```suggestion
       public Result<PageInfo<ProcessDefinition>> filterWorkflows(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
   ```



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/WorkflowV2Controller.java:
##########
@@ -0,0 +1,168 @@
+/*
+ * 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.dolphinscheduler.api.controller;
+
+import static org.apache.dolphinscheduler.api.enums.Status.CREATE_PROCESS_DEFINITION_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.DELETE_PROCESS_DEFINE_BY_CODE_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_PROCESS_DEFINITION_LIST;
+import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_PROCESS_DEFINITION_ERROR;
+
+import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
+import org.apache.dolphinscheduler.api.dto.PageResourceResponse;
+import org.apache.dolphinscheduler.api.dto.ResourceResponse;
+import org.apache.dolphinscheduler.api.dto.workflow.WorkflowCreateRequest;
+import org.apache.dolphinscheduler.api.dto.workflow.WorkflowFilterRequest;
+import org.apache.dolphinscheduler.api.dto.workflow.WorkflowUpdateRequest;
+import org.apache.dolphinscheduler.api.enums.Status;
+import org.apache.dolphinscheduler.api.exceptions.ApiException;
+import org.apache.dolphinscheduler.api.service.ProcessDefinitionService;
+import org.apache.dolphinscheduler.api.utils.PageInfo;
+import org.apache.dolphinscheduler.api.utils.Result;
+import org.apache.dolphinscheduler.common.Constants;
+import org.apache.dolphinscheduler.dao.entity.ProcessDefinition;
+import org.apache.dolphinscheduler.dao.entity.User;
+
+import springfox.documentation.annotations.ApiIgnore;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestAttribute;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+
+/**
+ * workflow controller
+ */
+@Api(tags = "WORKFLOW_TAG")
+@RestController
+@RequestMapping("/v2/workflows")
+public class WorkflowV2Controller extends BaseController {
+
+    @Autowired
+    private ProcessDefinitionService processDefinitionService;
+
+    /**
+     * Create resource workflow
+     *
+     * @param loginUser             login user
+     * @param workflowCreateRequest the new workflow object will be created
+     * @return ResourceResponse object created
+     */
+    @ApiOperation(value = "create", notes = "CREATE_WORKFLOWS_NOTES")
+    @PostMapping(consumes = {"application/json"})
+    @ResponseStatus(HttpStatus.CREATED)
+    @ApiException(CREATE_PROCESS_DEFINITION_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public ResourceResponse createWorkflows(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                            @RequestBody WorkflowCreateRequest workflowCreateRequest) {
+        ProcessDefinition processDefinition =
+                processDefinitionService.createProcessDefinitionV2(loginUser, workflowCreateRequest);
+        return new ResourceResponse(processDefinition);
+    }
+
+    /**
+     * Delete workflow by code
+     *
+     * @param loginUser login user
+     * @param code      process definition code
+     * @return Result result object delete
+     */
+    @ApiOperation(value = "delete", notes = "DELETE_WORKFLOWS_NOTES")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "code", value = "WORKFLOW_CODE", dataTypeClass = long.class, example = "123456", required = true)
+    })
+    @DeleteMapping(value = "/{code}")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(DELETE_PROCESS_DEFINE_BY_CODE_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result deleteWorkflows(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                  @PathVariable("code") Long code) {
+        processDefinitionService.deleteProcessDefinitionByCode(loginUser, code);
+        return new Result(Status.SUCCESS);
+    }
+
+    /**
+     * Update resource workflow
+     *
+     * @param loginUser        login user
+     * @param code             workflow resource code you want to update
+     * @param workflowUpdateRequest workflowUpdateRequest
+     * @return ResourceResponse object updated
+     */
+    @ApiOperation(value = "update", notes = "UPDATE_WORKFLOWS_NOTES")
+    @PutMapping(value = "/{code}")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(UPDATE_PROCESS_DEFINITION_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public ResourceResponse updateWorkflows(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,

Review Comment:
   ```suggestion
       public Result<ProcessDefinition> updateWorkflows(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
   ```



-- 
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@dolphinscheduler.apache.org

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