diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index 1a9e83deeb..55452a32a9 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -1169,7 +1169,16 @@ public class ApiAutomationService { scenarioRequest.setProjectId(scenario.getProjectId()); scenarioRequest.setName(scenario.getName()); scenarioRequest.setId(scenario.getId()); - scenarioRequest.setApiScenarioModuleId(request.getApiScenarioModuleId()); + if (StringUtils.isEmpty(request.getApiScenarioModuleId())) { + scenarioRequest.setApiScenarioModuleId(scenario.getApiScenarioModuleId()); + } else { + scenarioRequest.setApiScenarioModuleId(request.getApiScenarioModuleId()); + } + if (StringUtils.isEmpty(request.getModulePath())) { + scenarioRequest.setModulePath(scenario.getModulePath()); + } else { + scenarioRequest.setModulePath(request.getModulePath()); + } scenarioRequest.setModulePath(request.getModulePath()); scenarioRequest.setVersionId(scenario.getVersionId()); checkNameExist(scenarioRequest, false); diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java index 63620a824e..817c90acc0 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -1600,13 +1600,25 @@ public class ApiDefinitionService { //检查是否同名 SaveApiDefinitionRequest apiDefinitionRequest = new SaveApiDefinitionRequest(); apiDefinitionRequest.setProjectId(api.getProjectId()); - apiDefinitionRequest.setMethod(api.getMethod()); + if (StringUtils.isEmpty(request.getMethod())) { + apiDefinitionRequest.setMethod(api.getMethod()); + } else { + apiDefinitionRequest.setMethod(request.getMethod()); + } apiDefinitionRequest.setProtocol(api.getProtocol()); apiDefinitionRequest.setPath(api.getPath()); apiDefinitionRequest.setName(api.getName()); apiDefinitionRequest.setId(api.getId()); - apiDefinitionRequest.setModuleId(request.getModuleId()); - apiDefinitionRequest.setModulePath(request.getModulePath()); + if (StringUtils.isEmpty(request.getModuleId())) { + apiDefinitionRequest.setModuleId(api.getModuleId()); + } else { + apiDefinitionRequest.setMethod((request.getModuleId())); + } + if (StringUtils.isEmpty(request.getModulePath())) { + apiDefinitionRequest.setModulePath(api.getModulePath()); + } else { + apiDefinitionRequest.setModulePath(request.getModulePath()); + } apiDefinitionRequest.setVersionId(api.getVersionId()); checkNameExist(apiDefinitionRequest, false); });