From 08f768ab01d21807e4f4c00d515b949d560adc85 Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Mon, 4 Jul 2022 15:55:02 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AF=BC=E5=85=A5=E6=8E=A5=E5=8F=A3=E5=AF=B9?= =?UTF-8?q?ref=E7=9A=84=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --user=郭雨琦 --- .../api/service/ApiDefinitionService.java | 8 +- .../mapper/ext/ExtApiDefinitionMapper.xml | 2 +- .../base/mapper/ext/ExtLoadTestMapper.xml | 102 +++++++++--------- .../ext/ExtSwaggerUrlScheduleMapper.xml | 2 +- 4 files changed, 62 insertions(+), 52 deletions(-) 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 d6f0465d24..03bc72c181 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -1335,6 +1335,10 @@ public class ApiDefinitionService { MSException.throwException(Translator.get("connection_timeout")); } } + Project project = projectMapper.selectByPrimaryKey(request.getProjectId()); + if (StringUtils.equals(request.getType(), "schedule")) { + request.setProtocol("HTTP"); + } try { apiImport = (ApiDefinitionImport) Objects.requireNonNull(runService).parse(file == null ? null : file.getInputStream(), request); if (apiImport.getMocks() == null) { @@ -1356,7 +1360,7 @@ public class ApiDefinitionService { paramMap.put("url", request.getSwaggerUrl()); paramMap.put("projectId", request.getProjectId()); NoticeModel noticeModel = NoticeModel.builder() - .operator(SessionUtils.getUserId()) + .operator(project.getCreateUser()) .context(context) .testId(scheduleId) .subject(Translator.get("swagger_url_scheduled_import_notification")) @@ -1381,7 +1385,7 @@ public class ApiDefinitionService { Map paramMap = new HashMap<>(); paramMap.put("url", request.getSwaggerUrl()); NoticeModel noticeModel = NoticeModel.builder() - .operator(SessionUtils.getUserId()) + .operator(project.getCreateUser()) .context(context) .testId(scheduleId) .subject(Translator.get("swagger_url_scheduled_import_notification")) diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml index d55958ef5a..c80b596b07 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml @@ -1018,7 +1018,7 @@ UPDATE api_definition SET latest = 0 - and ref_id = #{refId} + where ref_id = #{refId} diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestMapper.xml index 499b415dc9..c948c73e18 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestMapper.xml @@ -109,9 +109,10 @@ parameterType="io.metersphere.performance.request.QueryTestPlanRequest"> SELECT load_test.*, project.name AS project_name, user.name AS user_name, project_version.name as version_name FROM load_test - LEFT JOIN project ON load_test.project_id = project.id - LEFT JOIN user ON load_test.user_id = user.id - LEFT JOIN project_version on project.id = project_version.project_id AND project_version.id = load_test.version_id + LEFT JOIN project ON load_test.project_id = project.id + LEFT JOIN user ON load_test.user_id = user.id + LEFT JOIN project_version on project.id = project_version.project_id AND project_version.id = + load_test.version_id @@ -197,7 +198,7 @@ SELECT file_metadata.* FROM file_metadata @@ -338,10 +341,14 @@ SELECT DISTINCT ref_id FROM load_test WHERE ref_id NOT IN ( - SELECT DISTINCT ref_id - FROM load_test - WHERE version_id = #{versionId} AND project_id = #{projectId} - ) AND project_id = #{projectId} + SELECT DISTINCT ref_id + FROM load_test + WHERE version_id = #{versionId} + AND project_id = #{projectId} + ) + AND project_id = #{projectId} diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtSwaggerUrlScheduleMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtSwaggerUrlScheduleMapper.xml index e803a7256b..60b6707435 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtSwaggerUrlScheduleMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtSwaggerUrlScheduleMapper.xml @@ -12,7 +12,7 @@ sup.config, sch.value as rule, sch.enable, - sch.id as taskId + sch.id as taskId FROM swagger_url_project sup INNER JOIN schedule sch ON sup.id = sch.resource_id WHERE sup.project_id = #{projectId}