-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature-14214][Parameter] Support CRUD of project-level parameters (#…
- Loading branch information
1 parent
4fa0ab4
commit 1c935d9
Showing
13 changed files
with
766 additions
and
3 deletions.
There are no files selected for viewing
169 changes: 169 additions & 0 deletions
169
.../src/main/java/org/apache/dolphinscheduler/api/controller/ProjectParameterController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
/* | ||
* 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_PROJECT_PARAMETER_ERROR; | ||
import static org.apache.dolphinscheduler.api.enums.Status.DELETE_PROJECT_PARAMETER_ERROR; | ||
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_PROJECT_PARAMETER_ERROR; | ||
import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_PROJECT_PARAMETER_ERROR; | ||
|
||
import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation; | ||
import org.apache.dolphinscheduler.api.exceptions.ApiException; | ||
import org.apache.dolphinscheduler.api.service.ProjectParameterService; | ||
import org.apache.dolphinscheduler.api.utils.Result; | ||
import org.apache.dolphinscheduler.common.constants.Constants; | ||
import org.apache.dolphinscheduler.dao.entity.User; | ||
import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.HttpStatus; | ||
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.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.Parameters; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
|
||
@Tag(name = "PROJECT_PARAMETER_TAG") | ||
@RestController | ||
@RequestMapping("projects/{projectCode}/project-parameter") | ||
@Slf4j | ||
public class ProjectParameterController extends BaseController { | ||
|
||
@Autowired | ||
private ProjectParameterService projectParameterService; | ||
|
||
@Operation(summary = "createProjectParameter", description = "CREATE_PROJECT_PARAMETER_NOTES") | ||
@Parameters({ | ||
@Parameter(name = "projectParameterName", description = "PROJECT_PARAMETER_NAME", schema = @Schema(implementation = String.class)), | ||
@Parameter(name = "projectParameterValue", description = "PROJECT_PARAMETER_VALUE", schema = @Schema(implementation = String.class)) | ||
}) | ||
@PostMapping() | ||
@ResponseStatus(HttpStatus.CREATED) | ||
@ApiException(CREATE_PROJECT_PARAMETER_ERROR) | ||
@AccessLogAnnotation(ignoreRequestArgs = "loginUser") | ||
public Result createProjectParameter(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser, | ||
@Parameter(name = "projectCode", description = "PROJECT_CODE", required = true) @PathVariable long projectCode, | ||
@RequestParam("projectParameterName") String projectParameterName, | ||
@RequestParam(value = "projectParameterValue") String projectParameterValue) { | ||
return projectParameterService.createProjectParameter(loginUser, projectCode, projectParameterName, | ||
projectParameterValue); | ||
} | ||
|
||
@Operation(summary = "updateProjectParameter", description = "UPDATE_PROJECT_PARAMETER_NOTES") | ||
@Parameters({ | ||
@Parameter(name = "code", description = "PROJECT_PARAMETER_CODE", schema = @Schema(implementation = long.class, example = "123456")), | ||
@Parameter(name = "projectParameterName", description = "PROJECT_PARAMETER_NAME", schema = @Schema(implementation = String.class)), | ||
@Parameter(name = "projectParameterValue", description = "PROJECT_PARAMETER_VALUE", schema = @Schema(implementation = String.class)), | ||
}) | ||
@PutMapping(value = "/{code}") | ||
@ResponseStatus(HttpStatus.OK) | ||
@ApiException(UPDATE_PROJECT_PARAMETER_ERROR) | ||
@AccessLogAnnotation(ignoreRequestArgs = "loginUser") | ||
public Result updateProjectParameter(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser, | ||
@Parameter(name = "projectCode", description = "PROJECT_CODE", required = true) @PathVariable long projectCode, | ||
@PathVariable("code") Long code, | ||
@RequestParam("projectParameterName") String projectParameterName, | ||
@RequestParam(value = "projectParameterValue") String projectParameterValue) { | ||
return projectParameterService.updateProjectParameter(loginUser, projectCode, code, projectParameterName, | ||
projectParameterValue); | ||
} | ||
|
||
@Operation(summary = "deleteProjectParametersByCode", description = "DELETE_PROJECT_PARAMETER_NOTES") | ||
@Parameters({ | ||
@Parameter(name = "code", description = "PROJECT_PARAMETER_CODE", required = true, schema = @Schema(implementation = String.class)) | ||
}) | ||
@PostMapping(value = "/delete") | ||
@ResponseStatus(HttpStatus.OK) | ||
@ApiException(DELETE_PROJECT_PARAMETER_ERROR) | ||
@AccessLogAnnotation(ignoreRequestArgs = "loginUser") | ||
public Result deleteProjectParametersByCode(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser, | ||
@Parameter(name = "projectCode", description = "PROJECT_CODE", required = true) @PathVariable long projectCode, | ||
@RequestParam("code") long code) { | ||
|
||
return projectParameterService.deleteProjectParametersByCode(loginUser, projectCode, code); | ||
} | ||
|
||
@Operation(summary = "batchDeleteProjectParametersByCodes", description = "DELETE_PROJECT_PARAMETER_NOTES") | ||
@Parameters({ | ||
@Parameter(name = "codes", description = "PROJECT_PARAMETER_CODE", required = true, schema = @Schema(implementation = String.class)) | ||
}) | ||
@PostMapping(value = "/batch-delete") | ||
@ResponseStatus(HttpStatus.OK) | ||
@ApiException(DELETE_PROJECT_PARAMETER_ERROR) | ||
@AccessLogAnnotation(ignoreRequestArgs = "loginUser") | ||
public Result batchDeleteProjectParametersByCodes(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser, | ||
@Parameter(name = "projectCode", description = "PROJECT_CODE", required = true) @PathVariable long projectCode, | ||
@RequestParam("codes") String codes) { | ||
|
||
return projectParameterService.batchDeleteProjectParametersByCodes(loginUser, projectCode, codes); | ||
} | ||
|
||
@Operation(summary = "queryProjectParameterListPaging", description = "QUERY_PROJECT_PARAMETER_LIST_PAGING_NOTES") | ||
@Parameters({ | ||
@Parameter(name = "searchVal", description = "SEARCH_VAL", required = false, schema = @Schema(implementation = String.class)), | ||
@Parameter(name = "pageNo", description = "PAGE_NO", required = true, schema = @Schema(implementation = int.class, example = "1")), | ||
@Parameter(name = "pageSize", description = "PAGE_SIZE", required = true, schema = @Schema(implementation = int.class, example = "10")) | ||
}) | ||
@GetMapping() | ||
@ResponseStatus(HttpStatus.OK) | ||
@ApiException(QUERY_PROJECT_PARAMETER_ERROR) | ||
@AccessLogAnnotation(ignoreRequestArgs = "loginUser") | ||
public Result queryProjectParameterListPaging( | ||
@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser, | ||
@Parameter(name = "projectCode", description = "PROJECT_CODE", required = true) @PathVariable long projectCode, | ||
@RequestParam(value = "searchVal", required = false) String searchVal, | ||
@RequestParam("pageNo") Integer pageNo, | ||
@RequestParam("pageSize") Integer pageSize) { | ||
|
||
Result result = checkPageParams(pageNo, pageSize); | ||
if (!result.checkResult()) { | ||
log.warn("Pagination parameters check failed, pageNo:{}, pageSize:{}", pageNo, pageSize); | ||
return result; | ||
} | ||
searchVal = ParameterUtils.handleEscapes(searchVal); | ||
return projectParameterService.queryProjectParameterListPaging(loginUser, projectCode, pageSize, pageNo, | ||
searchVal); | ||
} | ||
|
||
@Operation(summary = "queryProjectParameterByCode", description = "QUERY_PROJECT_PARAMETER_NOTES") | ||
@Parameters({ | ||
@Parameter(name = "code", description = "PROJECT_PARAMETER_CODE", schema = @Schema(implementation = long.class, example = "123456")) | ||
}) | ||
@GetMapping(value = "/{code}") | ||
@ResponseStatus(HttpStatus.OK) | ||
@ApiException(QUERY_PROJECT_PARAMETER_ERROR) | ||
@AccessLogAnnotation(ignoreRequestArgs = "loginUser") | ||
public Result queryProjectParameterByCode(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser, | ||
@Parameter(name = "projectCode", description = "PROJECT_CODE", required = true) @PathVariable long projectCode, | ||
@PathVariable("code") long code) { | ||
return projectParameterService.queryProjectParameterByCode(loginUser, projectCode, code); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...er-api/src/main/java/org/apache/dolphinscheduler/api/service/ProjectParameterService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.service; | ||
|
||
import org.apache.dolphinscheduler.api.utils.Result; | ||
import org.apache.dolphinscheduler.dao.entity.User; | ||
|
||
public interface ProjectParameterService { | ||
|
||
Result createProjectParameter(User loginUser, long projectCode, String projectParameterName, | ||
String projectParameterValue); | ||
|
||
Result updateProjectParameter(User loginUser, long projectCode, long code, String projectParameterName, | ||
String projectParameterValue); | ||
|
||
Result deleteProjectParametersByCode(User loginUser, long projectCode, long code); | ||
|
||
Result batchDeleteProjectParametersByCodes(User loginUser, long projectCode, String codes); | ||
|
||
Result queryProjectParameterListPaging(User loginUser, long projectCode, Integer pageSize, Integer pageNo, | ||
String searchVal); | ||
|
||
Result queryProjectParameterByCode(User loginUser, long projectCode, long code); | ||
} |
Oops, something went wrong.