caishunfeng commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r928360276


##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesController.java:
##########
@@ -146,7 +151,7 @@ public Result<Object> createDirectory(@ApiIgnore 
@RequestAttribute(value = Const
     @PostMapping()
     @ApiException(CREATE_RESOURCE_ERROR)
     @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
-    public Result<Object> createResource(@ApiIgnore @RequestAttribute(value = 
Constants.SESSION_USER) User loginUser,
+    public Result<org.apache.dolphinscheduler.dao.entity.Resource> 
createResource(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) 
User loginUser,

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



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesV2Controller.java:
##########
@@ -0,0 +1,770 @@
+/*
+ * 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.AUTHORIZED_FILE_RESOURCE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.AUTHORIZED_UDF_FUNCTION_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.AUTHORIZE_RESOURCE_TREE;
+import static 
org.apache.dolphinscheduler.api.enums.Status.CREATE_RESOURCE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.CREATE_RESOURCE_FILE_ON_LINE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.CREATE_UDF_FUNCTION_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.DELETE_RESOURCE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.DELETE_UDF_FUNCTION_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.DOWNLOAD_RESOURCE_FILE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.EDIT_RESOURCE_FILE_ON_LINE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.QUERY_DATASOURCE_BY_TYPE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.QUERY_RESOURCES_LIST_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.QUERY_RESOURCES_LIST_PAGING;
+import static 
org.apache.dolphinscheduler.api.enums.Status.QUERY_UDF_FUNCTION_LIST_PAGING_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.RESOURCE_FILE_IS_EMPTY;
+import static org.apache.dolphinscheduler.api.enums.Status.RESOURCE_NOT_EXIST;
+import static 
org.apache.dolphinscheduler.api.enums.Status.UNAUTHORIZED_UDF_FUNCTION_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.UPDATE_RESOURCE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.UPDATE_UDF_FUNCTION_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.VERIFY_RESOURCE_BY_NAME_AND_TYPE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.VERIFY_UDF_FUNCTION_NAME_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.VIEW_RESOURCE_FILE_ON_LINE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.VIEW_UDF_FUNCTION_ERROR;
+
+import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
+import org.apache.dolphinscheduler.api.dto.resources.CreateDirectoryRequest;
+import org.apache.dolphinscheduler.api.dto.resources.CreateResourceRequest;
+import org.apache.dolphinscheduler.api.dto.resources.CreateResourceResponse;
+import org.apache.dolphinscheduler.api.dto.resources.CreateUdfRequest;
+import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent;
+import org.apache.dolphinscheduler.api.dto.resources.ResourceContent;
+import org.apache.dolphinscheduler.api.dto.resources.ResourceContentResponse;
+import org.apache.dolphinscheduler.api.dto.resources.ResourceListResponse;
+import org.apache.dolphinscheduler.api.dto.resources.ResourcePageResponse;
+import org.apache.dolphinscheduler.api.dto.resources.ResourceResponse;
+import org.apache.dolphinscheduler.api.dto.resources.UdfFuncListResponse;
+import org.apache.dolphinscheduler.api.dto.resources.UdfFuncPageResponse;
+import org.apache.dolphinscheduler.api.dto.resources.UdfFuncResponse;
+import 
org.apache.dolphinscheduler.api.dto.resources.UpdateResourceContentRequest;
+import org.apache.dolphinscheduler.api.dto.resources.UpdateResourceResponse;
+import org.apache.dolphinscheduler.api.exceptions.ApiException;
+import org.apache.dolphinscheduler.api.service.ResourcesService;
+import org.apache.dolphinscheduler.api.service.UdfFuncService;
+import org.apache.dolphinscheduler.api.utils.PageInfo;
+import org.apache.dolphinscheduler.api.utils.Result;
+import org.apache.dolphinscheduler.common.Constants;
+import org.apache.dolphinscheduler.common.enums.ProgramType;
+import org.apache.dolphinscheduler.common.enums.UdfType;
+import org.apache.dolphinscheduler.common.utils.ParameterUtils;
+import org.apache.dolphinscheduler.dao.entity.Resource;
+import org.apache.dolphinscheduler.dao.entity.UdfFunc;
+import org.apache.dolphinscheduler.dao.entity.User;
+import org.apache.dolphinscheduler.spi.enums.ResourceType;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+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.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import springfox.documentation.annotations.ApiIgnore;
+
+
+/**
+ * resources controller
+ */
+@Api(tags = "RESOURCES_TAG")
+@RestController
+@RequestMapping("/v2/resources")
+public class ResourcesV2Controller extends BaseController {
+
+    private static final Logger logger = 
LoggerFactory.getLogger(ResourcesV2Controller.class);
+
+    @Autowired
+    private ResourcesService resourceService;
+    @Autowired
+    private UdfFuncService udfFuncService;
+
+    /**
+     * create resource director
+     *
+     * @param loginUser              login user
+     * @param createDirectoryRequest create directory request
+     * @return create result code
+     */
+    @ApiOperation(value = "createDirectory", notes = "CREATE_RESOURCE_NOTES")
+    @PostMapping(value = "/directory", consumes = "application/json")
+    @ApiException(CREATE_RESOURCE_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public CreateResourceResponse createDirectory(@ApiIgnore 
@RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                                  @RequestBody 
CreateDirectoryRequest createDirectoryRequest) {
+        //todo verify the directory name

Review Comment:
   It's better to put this todo into service.



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/BaseService.java:
##########
@@ -76,6 +76,14 @@ public interface BaseService {
      */
     void putMsg(Result<Object> result, Status status, Object... statusParams);
 
+    /**
+     * copy result msg from source to target
+     *
+     * @param        source source result
+     * @param        target target result
+     */
+    void copyMsg(Result source, Result target);
+

Review Comment:
   > I think it's unnessnary since we are doing V2 refactoring.
   
   +1, I think we don't need to copy result, because the old way is bad case, 
which should be optimized in the future.



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesController.java:
##########
@@ -119,7 +124,7 @@ public class ResourcesController extends BaseController {
     @PostMapping(value = "/directory")
     @ApiException(CREATE_RESOURCE_ERROR)
     @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
-    public Result<Object> createDirectory(@ApiIgnore @RequestAttribute(value = 
Constants.SESSION_USER) User loginUser,
+    public Result<org.apache.dolphinscheduler.dao.entity.Resource> 
createDirectory(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) 
User loginUser,

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



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesController.java:
##########
@@ -338,10 +343,10 @@ public Result<Object> queryResourceJarList(@ApiIgnore 
@RequestAttribute(value =
     @ResponseStatus(HttpStatus.OK)
     @ApiException(RESOURCE_NOT_EXIST)
     @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
-    public Result<Object> queryResource(@ApiIgnore @RequestAttribute(value = 
Constants.SESSION_USER) User loginUser,
-                                        @RequestParam(value = "fullName", 
required = false) String fullName,
-                                        @PathVariable(value = "id", required = 
false) Integer id,
-                                        @RequestParam(value = "type") 
ResourceType type
+    public Result<org.apache.dolphinscheduler.dao.entity.Resource> 
queryResource(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User 
loginUser,

Review Comment:
   same here



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to