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 2c86292493..aea99d60f0 100644 --- a/backend/src/main/java/io/metersphere/notice/sender/AfterReturningNoticeSendService.java +++ b/backend/src/main/java/io/metersphere/notice/sender/AfterReturningNoticeSendService.java @@ -3,7 +3,6 @@ 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; @@ -27,7 +26,7 @@ public class AfterReturningNoticeSendService { private NoticeSendService noticeSendService; @Async - public void sendNotice(SendNotice sendNotice, Object retValue, SessionUser sessionUser) { + public void sendNotice(SendNotice sendNotice, Object retValue, SessionUser sessionUser, String currentWorkspaceId) { // List resources = new ArrayList<>(); String source = sendNotice.source(); @@ -51,7 +50,7 @@ public class AfterReturningNoticeSendService { paramMap.put("url", baseSystemConfigDTO.getUrl()); paramMap.put("operator", sessionUser.getName()); paramMap.putAll(resource); - paramMap.putIfAbsent("projectId", SessionUtils.getCurrentProjectId()); + paramMap.putIfAbsent("workspaceId", currentWorkspaceId); // 占位符 handleDefaultValues(paramMap); diff --git a/backend/src/main/java/io/metersphere/notice/sender/SendNoticeAspect.java b/backend/src/main/java/io/metersphere/notice/sender/SendNoticeAspect.java index 79249dda2e..31a704c783 100644 --- a/backend/src/main/java/io/metersphere/notice/sender/SendNoticeAspect.java +++ b/backend/src/main/java/io/metersphere/notice/sender/SendNoticeAspect.java @@ -123,7 +123,8 @@ public class SendNoticeAspect { context.setVariable(params[len], args[len]); } SessionUser sessionUser = SessionUtils.getUser(); - afterReturningNoticeSendService.sendNotice(sendNotice, retValue, sessionUser); + String currentWorkspaceId = SessionUtils.getCurrentWorkspaceId(); + afterReturningNoticeSendService.sendNotice(sendNotice, retValue, sessionUser, currentWorkspaceId); } catch (Exception e) { LogUtil.error(e.getMessage(), e); } 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 d53ef849b5..939afa9f05 100644 --- a/backend/src/main/java/io/metersphere/notice/service/NoticeSendService.java +++ b/backend/src/main/java/io/metersphere/notice/service/NoticeSendService.java @@ -61,8 +61,13 @@ public class NoticeSendService { */ public void send(String taskType, NoticeModel noticeModel) { try { - String projectId = (String) noticeModel.getParamMap().get("projectId"); - List messageDetails = noticeService.searchMessageByTypeAndProjectId(taskType, projectId); + String workspaceId = (String) noticeModel.getParamMap().get("workspaceId"); + List messageDetails; + if (StringUtils.isEmpty(workspaceId)) { + messageDetails = noticeService.searchMessageByType(taskType); + } else { + messageDetails = noticeService.searchMessageByTypeAndWorkspaceId(taskType, workspaceId); + } // 异步发送通知 messageDetails.stream() @@ -133,7 +138,7 @@ public class NoticeSendService { // default: // break; // } - messageDetails = noticeService.searchMessageByTypeAndProjectId(taskType, project.getId()); + messageDetails = noticeService.searchMessageByTypeAndWorkspaceId(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 815cc324ba..77b3d89cfd 100644 --- a/backend/src/main/java/io/metersphere/notice/service/NoticeService.java +++ b/backend/src/main/java/io/metersphere/notice/service/NoticeService.java @@ -121,9 +121,9 @@ public class NoticeService { } } - public List searchMessageByTypeAndProjectId(String type, String projectId) { + public List searchMessageByTypeAndWorkspaceId(String type, String workspaceId) { try { - return getMessageDetails(type, projectId); + return getMessageDetails(type, workspaceId); } catch (Exception e) { LogUtil.error(e.getMessage(), e); return new ArrayList<>();