From 0261109580d3e6d03932d9f196e36c876d59e83c Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Wed, 26 May 2021 18:45:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=96=B0=E5=BB=BA=E6=8E=A5=E5=8F=A3=E6=97=B6?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E7=82=B9=E5=87=BB=E6=B5=8B=E8=AF=95=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E5=87=BA=E7=8E=B0=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复接口定义新建接口时直接点击测试按钮出现报错的问题 --- .../api/controller/ApiDefinitionController.java | 4 ++-- .../io/metersphere/api/service/ApiDefinitionService.java | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java b/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java index 1079616365..2b0da965de 100644 --- a/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java +++ b/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java @@ -97,9 +97,9 @@ public class ApiDefinitionController { @PostMapping(value = "/create", consumes = {"multipart/form-data"}) @RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ_CREATE_API) @MsAuditLog(module = "api_definition", type = OperLogConstants.CREATE, title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = ApiDefinitionService.class) - public void create(@RequestPart("request") SaveApiDefinitionRequest request, @RequestPart(value = "files") List bodyFiles) { + public ApiDefinitionWithBLOBs create(@RequestPart("request") SaveApiDefinitionRequest request, @RequestPart(value = "files") List bodyFiles) { checkPermissionService.checkProjectOwner(request.getProjectId()); - apiDefinitionService.create(request, bodyFiles); + return apiDefinitionService.create(request, bodyFiles); } @PostMapping(value = "/update", consumes = {"multipart/form-data"}) 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 5707d093cc..6446f5d240 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -181,12 +181,13 @@ public class ApiDefinitionService { } } - public void create(SaveApiDefinitionRequest request, List bodyFiles) { + public ApiDefinitionWithBLOBs create(SaveApiDefinitionRequest request, List bodyFiles) { if (StringUtils.equals(request.getProtocol(), "DUBBO")) { request.setMethod("dubbo://"); } - createTest(request); + ApiDefinitionWithBLOBs returnModel = createTest(request); FileUtils.createBodyFiles(request.getRequest().getId(), bodyFiles); + return returnModel; } public ApiDefinitionWithBLOBs update(SaveApiDefinitionRequest request, List bodyFiles) { @@ -315,7 +316,7 @@ public class ApiDefinitionService { return test; } - private ApiDefinition createTest(SaveApiDefinitionRequest request) { + private ApiDefinitionWithBLOBs createTest(SaveApiDefinitionRequest request) { checkNameExist(request); if (StringUtils.equals(request.getMethod(), "ESB")) { //ESB的接口类型数据,采用TCP方式去发送。并将方法类型改为TCP。 并修改发送数据