From f7d684265622795c2bd06fc45956865ac878aea6 Mon Sep 17 00:00:00 2001 From: CaptainB Date: Tue, 8 Mar 2022 10:39:48 +0800 Subject: [PATCH] =?UTF-8?q?perf(=E6=B6=88=E6=81=AF=E9=80=9A=E7=9F=A5):=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8F=91=E9=80=81=E9=80=9A=E7=9F=A5=E7=9A=84?= =?UTF-8?q?=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1010865 --user=刘瑞斌 【测试跟踪】批量移动功能用例耗时较长 https://www.tapd.cn/55049933/s/1114701 --- .../api/service/ApiDefinitionService.java | 1 + .../notice/controller/NoticeController.java | 4 +++- .../sender/AfterReturningNoticeSendService.java | 2 ++ .../notice/service/NoticeSendService.java | 5 +++-- .../metersphere/notice/service/NoticeService.java | 15 ++------------- 5 files changed, 11 insertions(+), 16 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 0ec275a978..76624c50f3 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -1136,6 +1136,7 @@ public class ApiDefinitionService { String context = request.getSwaggerUrl() + "导入失败"; Map paramMap = new HashMap<>(); paramMap.put("url", request.getSwaggerUrl()); + paramMap.put("projectId", request.getProjectId()); NoticeModel noticeModel = NoticeModel.builder() .operator(SessionUtils.getUserId()) .context(context) diff --git a/backend/src/main/java/io/metersphere/notice/controller/NoticeController.java b/backend/src/main/java/io/metersphere/notice/controller/NoticeController.java index efd5b30723..9dbecfb157 100644 --- a/backend/src/main/java/io/metersphere/notice/controller/NoticeController.java +++ b/backend/src/main/java/io/metersphere/notice/controller/NoticeController.java @@ -2,6 +2,7 @@ package io.metersphere.notice.controller; import io.metersphere.commons.constants.OperLogConstants; import io.metersphere.commons.constants.OperLogModule; +import io.metersphere.commons.utils.SessionUtils; import io.metersphere.log.annotation.MsAuditLog; import io.metersphere.notice.domain.MessageDetail; import io.metersphere.notice.service.NoticeService; @@ -24,7 +25,8 @@ public class NoticeController { @GetMapping("/search/message/type/{type}") public List searchMessage(@PathVariable String type) { - return noticeService.searchMessageByType(type); + String projectId = SessionUtils.getCurrentProjectId(); + return noticeService.searchMessageByTypeAndProjectId(type, projectId); } @GetMapping("/search/message/{testId}") diff --git a/backend/src/main/java/io/metersphere/notice/sender/AfterReturningNoticeSendService.java b/backend/src/main/java/io/metersphere/notice/sender/AfterReturningNoticeSendService.java index 4f9d57e49f..2c86292493 100644 --- a/backend/src/main/java/io/metersphere/notice/sender/AfterReturningNoticeSendService.java +++ b/backend/src/main/java/io/metersphere/notice/sender/AfterReturningNoticeSendService.java @@ -3,6 +3,7 @@ package io.metersphere.notice.sender; import com.alibaba.fastjson.JSON; import io.metersphere.commons.constants.NoticeConstants; import io.metersphere.commons.user.SessionUser; +import io.metersphere.commons.utils.SessionUtils; import io.metersphere.dto.BaseSystemConfigDTO; import io.metersphere.notice.annotation.SendNotice; import io.metersphere.notice.service.NoticeSendService; @@ -50,6 +51,7 @@ public class AfterReturningNoticeSendService { paramMap.put("url", baseSystemConfigDTO.getUrl()); paramMap.put("operator", sessionUser.getName()); paramMap.putAll(resource); + paramMap.putIfAbsent("projectId", SessionUtils.getCurrentProjectId()); // 占位符 handleDefaultValues(paramMap); diff --git a/backend/src/main/java/io/metersphere/notice/service/NoticeSendService.java b/backend/src/main/java/io/metersphere/notice/service/NoticeSendService.java index c9cb8e700e..d53ef849b5 100644 --- a/backend/src/main/java/io/metersphere/notice/service/NoticeSendService.java +++ b/backend/src/main/java/io/metersphere/notice/service/NoticeSendService.java @@ -61,7 +61,8 @@ public class NoticeSendService { */ public void send(String taskType, NoticeModel noticeModel) { try { - List messageDetails = noticeService.searchMessageByType(taskType); + String projectId = (String) noticeModel.getParamMap().get("projectId"); + List messageDetails = noticeService.searchMessageByTypeAndProjectId(taskType, projectId); // 异步发送通知 messageDetails.stream() @@ -132,7 +133,7 @@ public class NoticeSendService { // default: // break; // } - messageDetails = noticeService.searchMessageByTypeAndWorkspaceId(taskType, project.getWorkspaceId()); + messageDetails = noticeService.searchMessageByTypeAndProjectId(taskType, project.getId()); // 异步发送通知 messageDetails.stream() diff --git a/backend/src/main/java/io/metersphere/notice/service/NoticeService.java b/backend/src/main/java/io/metersphere/notice/service/NoticeService.java index 1e2c205189..278aeda102 100644 --- a/backend/src/main/java/io/metersphere/notice/service/NoticeService.java +++ b/backend/src/main/java/io/metersphere/notice/service/NoticeService.java @@ -111,20 +111,9 @@ public class NoticeService { return scheduleMessageTask; } - public List searchMessageByType(String type) { + public List searchMessageByTypeAndProjectId(String type, String projectId) { try { - String workspaceId = SessionUtils.getCurrentWorkspaceId(); - return getMessageDetails(type, workspaceId); - } catch (Exception e) { - LogUtil.error(e.getMessage(), e); - return new ArrayList<>(); - } - } - - - public List searchMessageByTypeAndWorkspaceId(String type, String workspaceId) { - try { - return getMessageDetails(type, workspaceId); + return getMessageDetails(type, projectId); } catch (Exception e) { LogUtil.error(e.getMessage(), e); return new ArrayList<>();