From 99261a56c47d6d3da40c7469cf03e01af77454ac Mon Sep 17 00:00:00 2001 From: metersphere-bot <78466014+metersphere-bot@users.noreply.github.com> Date: Tue, 7 Sep 2021 16:02:38 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=AB=99=E5=86=85=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC=20(#5999)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 站内通知跳转 Co-authored-by: Captain.B --- .../ApiDefinitionExecResultService.java | 1 - .../api/service/ApiScenarioReportService.java | 1 - .../base/mapper/ext/ExtProjectMapper.java | 4 +- .../base/mapper/ext/ExtProjectMapper.xml | 156 +++++++++++++----- .../controller/UserController.java | 9 +- .../notice/PerformanceNoticeEvent.java | 1 - .../io/metersphere/service/UserService.java | 22 ++- .../notice/components/MentionedMeData.vue | 30 +++- .../notice/components/SystemNoticeData.vue | 30 +++- .../src/business/components/notice/util.js | 51 ++++++ 10 files changed, 251 insertions(+), 54 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java index 5b06d75fd5..ba4b181169 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java @@ -160,7 +160,6 @@ public class ApiDefinitionExecResultService { .failedMailTemplate("api/CaseResult") .paramMap(paramMap) .event(event) - .excludeSelf(true) .build(); String taskType = NoticeConstants.TaskType.API_DEFINITION_TASK; diff --git a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java index 28c56f393b..5e60cdd7b0 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java @@ -643,7 +643,6 @@ public class ApiScenarioReportService { .failedMailTemplate("api/ScenarioResult") .paramMap(paramMap) .event(event) - .excludeSelf(true) .build(); String taskType = NoticeConstants.TaskType.API_AUTOMATION_TASK; diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.java index edcd176623..6d860be9ea 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.java @@ -29,7 +29,9 @@ public interface ExtProjectMapper { @MapKey("id") Map queryNameByIds(@Param("ids") List ids); - Organization getOrganizationByProjectId(@Param("projectId")String projectId); + Organization getOrganizationByProjectId(@Param("projectId") String projectId); List selectTcpPorts(); + + Project selectProjectByResourceId(@Param("resourceId") String resourceId); } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.xml index 1bb1de862a..aa7b9b6f10 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.xml @@ -32,13 +32,29 @@ - update project + UPDATE project - jira_key = null + jira_key = NULL - tapd_id = null + tapd_id = NULL + - zentao_id = null + + zentao_id = NULL + - azure_devops_id = null + + azure_devops_id = NULL - where project.id in (select id from (select id - from project - where workspace_id in - (select workspace.id - from workspace - where organization_id = #{orgId})) as a) + WHERE project.id IN (SELECT id FROM (SELECT id + FROM project + WHERE workspace_id IN + (SELECT workspace.id + FROM workspace + WHERE organization_id = #{orgId})) AS a) SELECT mock_tcp_port FROM project - WHERE mock_tcp_port is not null and mock_tcp_port != 0 + WHERE mock_tcp_port IS NOT NULL + AND mock_tcp_port != 0 + diff --git a/backend/src/main/java/io/metersphere/controller/UserController.java b/backend/src/main/java/io/metersphere/controller/UserController.java index a9feeae452..bb4810cfb6 100644 --- a/backend/src/main/java/io/metersphere/controller/UserController.java +++ b/backend/src/main/java/io/metersphere/controller/UserController.java @@ -5,7 +5,6 @@ import com.github.pagehelper.PageHelper; import io.metersphere.base.domain.User; import io.metersphere.commons.constants.OperLogConstants; import io.metersphere.commons.exception.MSException; -import io.metersphere.commons.user.SessionUser; import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.Pager; import io.metersphere.commons.utils.SessionUtils; @@ -20,7 +19,6 @@ import io.metersphere.dto.*; import io.metersphere.excel.domain.ExcelResponse; import io.metersphere.i18n.Translator; import io.metersphere.log.annotation.MsAuditLog; -import io.metersphere.service.CheckPermissionService; import io.metersphere.service.OrganizationService; import io.metersphere.service.UserService; import io.metersphere.service.WorkspaceService; @@ -46,8 +44,6 @@ public class UserController { private OrganizationService organizationService; @Resource private WorkspaceService workspaceService; - @Resource - private CheckPermissionService checkPermissionService; @PostMapping("/special/add") @MsAuditLog(module = "system_user", type = OperLogConstants.CREATE, content = "#msClass.getLogDetails(#user)", msClass = UserService.class) @@ -148,6 +144,11 @@ public class UserController { return userService.updateCurrentUser(user); } + @GetMapping("/update/currentByResourceId/{resourceId}") + public void updateCurrentUserByResourceId(@PathVariable String resourceId) { + userService.updateCurrentUserByResourceId(resourceId); + } + @PostMapping("/switch/source/org/{sourceId}") public UserDTO switchOrganization(@PathVariable(value = "sourceId") String sourceId) { userService.switchUserRole("organization", sourceId); diff --git a/backend/src/main/java/io/metersphere/performance/notice/PerformanceNoticeEvent.java b/backend/src/main/java/io/metersphere/performance/notice/PerformanceNoticeEvent.java index 36c52ee34e..3ca415a7a4 100644 --- a/backend/src/main/java/io/metersphere/performance/notice/PerformanceNoticeEvent.java +++ b/backend/src/main/java/io/metersphere/performance/notice/PerformanceNoticeEvent.java @@ -101,7 +101,6 @@ public class PerformanceNoticeEvent implements LoadTestFinishEvent { .subject(subject) .event(NoticeConstants.Event.EXECUTE_COMPLETED) .paramMap(paramMap) - .excludeSelf(true) .build(); noticeSendService.send(organization, NoticeConstants.TaskType.PERFORMANCE_TEST_TASK, noticeModel2); } diff --git a/backend/src/main/java/io/metersphere/service/UserService.java b/backend/src/main/java/io/metersphere/service/UserService.java index 2146fb1dc8..f5133393c8 100644 --- a/backend/src/main/java/io/metersphere/service/UserService.java +++ b/backend/src/main/java/io/metersphere/service/UserService.java @@ -5,10 +5,7 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import io.metersphere.base.domain.*; import io.metersphere.base.mapper.*; -import io.metersphere.base.mapper.ext.ExtOrganizationMapper; -import io.metersphere.base.mapper.ext.ExtUserGroupMapper; -import io.metersphere.base.mapper.ext.ExtUserMapper; -import io.metersphere.base.mapper.ext.ExtUserRoleMapper; +import io.metersphere.base.mapper.ext.*; import io.metersphere.commons.constants.*; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.user.SessionUser; @@ -97,6 +94,8 @@ public class UserService { private ExtUserGroupMapper extUserGroupMapper; @Resource private ProjectMapper projectMapper; + @Resource + private ExtProjectMapper extProjectMapper; public List queryTypeByIds(List userIds) { return extUserMapper.queryTypeByIds(userIds); @@ -1451,7 +1450,7 @@ public class UserService { User user = userMapper.selectByPrimaryKey(SessionUtils.getUserId()); String platformInfoStr = user.getPlatformInfo(); if (StringUtils.isBlank(orgId) || StringUtils.isBlank(platformInfoStr)) { - return null; + return null; } JSONObject platformInfos = JSONObject.parseObject(platformInfoStr); JSONObject platformInfo = platformInfos.getJSONObject(orgId); @@ -1460,4 +1459,17 @@ public class UserService { } return JSONObject.parseObject(JSONObject.toJSONString(platformInfo), UserDTO.PlatformInfo.class); } + + public void updateCurrentUserByResourceId(String resourceId) { + Project project = extProjectMapper.selectProjectByResourceId(resourceId); + if (project == null) { + return; + } + Workspace workspace = workspaceMapper.selectByPrimaryKey(project.getWorkspaceId()); + SessionUser user = SessionUtils.getUser(); + user.setLastProjectId(project.getId()); + user.setLastWorkspaceId(project.getWorkspaceId()); + user.setLastOrganizationId(workspace.getOrganizationId()); + userMapper.updateByPrimaryKeySelective(user); + } } diff --git a/frontend/src/business/components/notice/components/MentionedMeData.vue b/frontend/src/business/components/notice/components/MentionedMeData.vue index 54a99066e0..292b36446c 100644 --- a/frontend/src/business/components/notice/components/MentionedMeData.vue +++ b/frontend/src/business/components/notice/components/MentionedMeData.vue @@ -30,7 +30,10 @@ {{ item.user.name }} - {{ getOperation(item.operation) }}{{ getResource(item) }}: {{ item.resourceName }} + {{ getOperation(item.operation) }}{{ getResource(item) }}: + {{ item.resourceName }} + {{ item.resourceName }} @@ -43,7 +46,7 @@