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<>();