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 9dbecfb157..efd5b30723 100644 --- a/backend/src/main/java/io/metersphere/notice/controller/NoticeController.java +++ b/backend/src/main/java/io/metersphere/notice/controller/NoticeController.java @@ -2,7 +2,6 @@ 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; @@ -25,8 +24,7 @@ public class NoticeController { @GetMapping("/search/message/type/{type}") public List searchMessage(@PathVariable String type) { - String projectId = SessionUtils.getCurrentProjectId(); - return noticeService.searchMessageByTypeAndProjectId(type, projectId); + return noticeService.searchMessageByType(type); } @GetMapping("/search/message/{testId}") 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 278aeda102..815cc324ba 100644 --- a/backend/src/main/java/io/metersphere/notice/service/NoticeService.java +++ b/backend/src/main/java/io/metersphere/notice/service/NoticeService.java @@ -111,6 +111,16 @@ public class NoticeService { return scheduleMessageTask; } + public List searchMessageByType(String type) { + try { + String workspaceId = SessionUtils.getCurrentWorkspaceId(); + return getMessageDetails(type, workspaceId); + } catch (Exception e) { + LogUtil.error(e.getMessage(), e); + return new ArrayList<>(); + } + } + public List searchMessageByTypeAndProjectId(String type, String projectId) { try { return getMessageDetails(type, projectId); @@ -122,14 +132,8 @@ public class NoticeService { public List searchMessageByTypeBySend(String type, String projectId) { try { - String workspaceId = ""; - if (null == SessionUtils.getCurrentWorkspaceId()) { - Project project = projectMapper.selectByPrimaryKey(projectId); - workspaceId = project.getWorkspaceId(); - } else { - workspaceId = SessionUtils.getCurrentWorkspaceId(); - } - return getMessageDetails(type, workspaceId); + Project project = projectMapper.selectByPrimaryKey(projectId); + return getMessageDetails(type, project.getWorkspaceId()); } catch (Exception e) { LogUtil.error(e.getMessage(), e); return new ArrayList<>();