feat: 站内通知跳转 (#5999)
* feat: 站内通知跳转 Co-authored-by: Captain.B <bin@fit2cloud.com>
This commit is contained in:
parent
3657683c0e
commit
99261a56c4
|
@ -160,7 +160,6 @@ public class ApiDefinitionExecResultService {
|
|||
.failedMailTemplate("api/CaseResult")
|
||||
.paramMap(paramMap)
|
||||
.event(event)
|
||||
.excludeSelf(true)
|
||||
.build();
|
||||
|
||||
String taskType = NoticeConstants.TaskType.API_DEFINITION_TASK;
|
||||
|
|
|
@ -643,7 +643,6 @@ public class ApiScenarioReportService {
|
|||
.failedMailTemplate("api/ScenarioResult")
|
||||
.paramMap(paramMap)
|
||||
.event(event)
|
||||
.excludeSelf(true)
|
||||
.build();
|
||||
|
||||
String taskType = NoticeConstants.TaskType.API_AUTOMATION_TASK;
|
||||
|
|
|
@ -29,7 +29,9 @@ public interface ExtProjectMapper {
|
|||
@MapKey("id")
|
||||
Map<String, Project> queryNameByIds(@Param("ids") List<String> ids);
|
||||
|
||||
Organization getOrganizationByProjectId(@Param("projectId")String projectId);
|
||||
Organization getOrganizationByProjectId(@Param("projectId") String projectId);
|
||||
|
||||
List<Integer> selectTcpPorts();
|
||||
|
||||
Project selectProjectByResourceId(@Param("resourceId") String resourceId);
|
||||
}
|
||||
|
|
|
@ -32,13 +32,29 @@
|
|||
</sql>
|
||||
|
||||
<select id="getProjectWithWorkspace" resultType="io.metersphere.dto.ProjectDTO">
|
||||
select p.id, p.workspace_id, p.name, p.description, p.update_time, p.issue_template_id, p.case_template_id,
|
||||
p.create_time, w.id as workspaceId, w.name as workspaceName, p.tapd_id, p.jira_key, p.zentao_id,p.azure_devops_id,p.repeatable, p.custom_num,
|
||||
user.name as createUserName,p.mock_tcp_port AS mockTcpPort,p.is_mock_tcp_open AS isMockTcpOpen,
|
||||
p.scenario_custom_num
|
||||
from project p
|
||||
join workspace w on p.workspace_id = w.id
|
||||
left join user on user.id = p.create_user
|
||||
SELECT p.id,
|
||||
p.workspace_id,
|
||||
p.name,
|
||||
p.description,
|
||||
p.update_time,
|
||||
p.issue_template_id,
|
||||
p.case_template_id,
|
||||
p.create_time,
|
||||
w.id AS workspaceId,
|
||||
w.name AS workspaceName,
|
||||
p.tapd_id,
|
||||
p.jira_key,
|
||||
p.zentao_id,
|
||||
p.azure_devops_id,
|
||||
p.repeatable,
|
||||
p.custom_num,
|
||||
user.name AS createUserName,
|
||||
p.mock_tcp_port AS mockTcpPort,
|
||||
p.is_mock_tcp_open AS isMockTcpOpen,
|
||||
p.scenario_custom_num
|
||||
FROM project p
|
||||
JOIN workspace w ON p.workspace_id = w.id
|
||||
LEFT JOIN user ON user.id = p.create_user
|
||||
<where>
|
||||
<if test="proRequest.combine != null">
|
||||
<include refid="combine">
|
||||
|
@ -73,54 +89,61 @@
|
|||
</foreach>
|
||||
</if>
|
||||
<if test="proRequest.name != null and proRequest.name != ''">
|
||||
and p.name like #{proRequest.name, jdbcType=VARCHAR}
|
||||
AND p.name LIKE #{proRequest.name, jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="proRequest.workspaceId != null">
|
||||
and w.id = #{proRequest.workspaceId}
|
||||
AND w.id = #{proRequest.workspaceId}
|
||||
</if>
|
||||
<if test="proRequest.projectId != null">
|
||||
and p.id = #{proRequest.projectId}
|
||||
AND p.id = #{proRequest.projectId}
|
||||
</if>
|
||||
</where>
|
||||
<if test="proRequest.orders != null and proRequest.orders.size() > 0">
|
||||
order by
|
||||
ORDER BY
|
||||
<foreach collection="proRequest.orders" separator="," item="order">
|
||||
p.${order.name} ${order.type}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
<select id="getProjectIdByWorkspaceId" resultType="java.lang.String">
|
||||
select id
|
||||
from project
|
||||
where workspace_id = #{workspaceId}
|
||||
SELECT id
|
||||
FROM project
|
||||
WHERE workspace_id = #{workspaceId}
|
||||
</select>
|
||||
<select id="getUserProject" resultType="io.metersphere.dto.ProjectDTO">
|
||||
select distinct p.* from `group` g join user_group ug on g.id = ug.group_id
|
||||
join project p on p.id = ug.source_id
|
||||
SELECT DISTINCT p.*
|
||||
FROM `group` g
|
||||
JOIN user_group ug ON g.id = ug.group_id
|
||||
JOIN project p ON p.id = ug.source_id
|
||||
<where>
|
||||
g.type = 'PROJECT' and ug.user_id = #{proRequest.userId}
|
||||
g.type = 'PROJECT'
|
||||
AND ug.user_id = #{proRequest.userId}
|
||||
<if test="proRequest.workspaceId != null and proRequest.workspaceId != ''">
|
||||
and p.workspace_id = #{proRequest.workspaceId}
|
||||
AND p.workspace_id = #{proRequest.workspaceId}
|
||||
</if>
|
||||
<if test="proRequest.name != null and proRequest.name != ''">
|
||||
and p.name like #{proRequest.name, jdbcType=VARCHAR}
|
||||
AND p.name LIKE #{proRequest.name, jdbcType=VARCHAR}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="getSystemIdByProjectId" resultType="java.lang.String">
|
||||
SELECT system_id FROM project WHERE id = #{0}
|
||||
SELECT system_id
|
||||
FROM project
|
||||
WHERE id = #{0}
|
||||
</select>
|
||||
<select id="getProjectIds" resultType="java.lang.String">
|
||||
select id from project;
|
||||
SELECT id
|
||||
FROM project;
|
||||
</select>
|
||||
|
||||
<select id="getMaxSystemId" resultType="java.lang.String">
|
||||
SELECT max(system_id) FROM project
|
||||
SELECT MAX(system_id)
|
||||
FROM project
|
||||
</select>
|
||||
<select id="queryNameByIds" resultType="io.metersphere.base.domain.Project">
|
||||
select id, name, custom_num
|
||||
from project
|
||||
WHERE id IN
|
||||
SELECT id, name, custom_num
|
||||
FROM project
|
||||
WHERE id IN
|
||||
<foreach collection="ids" item="id" index="index"
|
||||
open="(" close=")" separator=",">
|
||||
#{id}
|
||||
|
@ -128,27 +151,31 @@
|
|||
</select>
|
||||
|
||||
<update id="removeIssuePlatform">
|
||||
update project
|
||||
UPDATE project
|
||||
<set>
|
||||
<if test="platform == 'Jira'">
|
||||
jira_key = null
|
||||
jira_key = NULL
|
||||
</if>
|
||||
<if test="platform == 'Tapd'">
|
||||
tapd_id = null
|
||||
tapd_id = NULL
|
||||
|
||||
</if>
|
||||
<if test="platform == 'Zentao'">
|
||||
zentao_id = null
|
||||
|
||||
zentao_id = NULL
|
||||
|
||||
</if>
|
||||
<if test="platform == 'AzureDevops'">
|
||||
azure_devops_id = null
|
||||
|
||||
azure_devops_id = NULL
|
||||
</if>
|
||||
</set>
|
||||
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)
|
||||
</update>
|
||||
|
||||
<select id="getOrganizationByProjectId" resultType="io.metersphere.base.domain.Organization">
|
||||
|
@ -162,7 +189,62 @@
|
|||
<select id="selectTcpPorts" resultType="java.lang.Integer">
|
||||
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
|
||||
</select>
|
||||
|
||||
<select id="selectProjectByResourceId" resultType="io.metersphere.base.domain.Project">
|
||||
SELECT *
|
||||
FROM project
|
||||
WHERE id IN (
|
||||
SELECT project_id
|
||||
FROM test_plan
|
||||
WHERE id = #{resourceId}
|
||||
UNION
|
||||
SELECT project_id
|
||||
FROM test_case_review
|
||||
WHERE id = #{resourceId}
|
||||
UNION
|
||||
SELECT project_id
|
||||
FROM issues
|
||||
WHERE id = #{resourceId}
|
||||
UNION
|
||||
SELECT project_id
|
||||
FROM test_plan_report
|
||||
JOIN test_plan tp ON tp.id = test_plan_report.test_plan_id
|
||||
WHERE test_plan_report.id = #{resourceId}
|
||||
UNION
|
||||
SELECT project_id
|
||||
FROM test_case
|
||||
WHERE id = #{resourceId}
|
||||
UNION
|
||||
SELECT project_id
|
||||
FROM swagger_url_project
|
||||
WHERE id = #{resourceId}
|
||||
UNION
|
||||
SELECT project_id
|
||||
FROM api_scenario
|
||||
WHERE id = #{resourceId}
|
||||
UNION
|
||||
SELECT project_id
|
||||
FROM api_definition
|
||||
WHERE id = #{resourceId}
|
||||
UNION
|
||||
SELECT project_id
|
||||
FROM api_test_case
|
||||
WHERE id = #{resourceId}
|
||||
UNION
|
||||
SELECT project_id
|
||||
FROM api_scenario_report
|
||||
WHERE id = #{resourceId}
|
||||
UNION
|
||||
SELECT project_id
|
||||
FROM load_test
|
||||
WHERE id = #{resourceId}
|
||||
UNION
|
||||
SELECT project_id
|
||||
FROM load_test_report
|
||||
WHERE id = #{resourceId})
|
||||
LIMIT 1
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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<UserDetail> queryTypeByIds(List<String> 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,10 @@
|
|||
</div>
|
||||
<span class="username">{{ item.user.name }}</span>
|
||||
<span class="operation">
|
||||
{{ getOperation(item.operation) }}{{ getResource(item) }}: {{ item.resourceName }}
|
||||
{{ getOperation(item.operation) }}{{ getResource(item) }}:
|
||||
<span v-if="item.resourceId && item.operation.indexOf('DELETE') < 0"
|
||||
@click="clickResource(item)" style="color: #783887; cursor: pointer;">{{ item.resourceName }}</span>
|
||||
<span v-else>{{ item.resourceName }}</span>
|
||||
</span>
|
||||
</el-row>
|
||||
</el-card>
|
||||
|
@ -43,7 +46,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import {getOperation, getResource} from "@/business/components/notice/util";
|
||||
import {getOperation, getResource, getUrl} from "@/business/components/notice/util";
|
||||
|
||||
export default {
|
||||
name: "MentionedMeData",
|
||||
|
@ -101,6 +104,29 @@ export default {
|
|||
this.goPage++;
|
||||
}
|
||||
this.init();
|
||||
},
|
||||
clickResource(resource) {
|
||||
let resourceId = resource.resourceId;
|
||||
if (!resourceId) {
|
||||
return;
|
||||
}
|
||||
let uri = getUrl(resource);
|
||||
|
||||
this.$get('/user/update/currentByResourceId/' + resourceId, () => {
|
||||
this.toPage(uri);
|
||||
});
|
||||
},
|
||||
toPage(uri) {
|
||||
let id = "new_a";
|
||||
let a = document.createElement("a");
|
||||
a.setAttribute("href", uri);
|
||||
a.setAttribute("target", "_blank");
|
||||
a.setAttribute("id", id);
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
|
||||
let element = document.getElementById(id);
|
||||
element.parentNode.removeChild(element);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -30,7 +30,10 @@
|
|||
</div>
|
||||
<span class="username">{{ item.user.name }}</span>
|
||||
<span class="operation">
|
||||
{{ getOperation(item.operation) }}{{ getResource(item) }}: {{ item.resourceName }}
|
||||
{{ getOperation(item.operation) }}{{ getResource(item) }}:
|
||||
<span v-if="item.resourceId && item.operation.indexOf('DELETE') < 0"
|
||||
@click="clickResource(item)" style="color: #783887; cursor: pointer;">{{ item.resourceName }}</span>
|
||||
<span v-else>{{ item.resourceName }}</span>
|
||||
</span>
|
||||
</el-row>
|
||||
</el-card>
|
||||
|
@ -43,7 +46,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import {getOperation, getResource} from "@/business/components/notice/util";
|
||||
import {getOperation, getResource, getUrl} from "@/business/components/notice/util";
|
||||
|
||||
export default {
|
||||
name: "SystemNoticeData",
|
||||
|
@ -100,6 +103,29 @@ export default {
|
|||
this.goPage++;
|
||||
}
|
||||
this.init();
|
||||
},
|
||||
clickResource(resource) {
|
||||
let resourceId = resource.resourceId;
|
||||
if (!resourceId) {
|
||||
return;
|
||||
}
|
||||
let uri = getUrl(resource);
|
||||
|
||||
this.$get('/user/update/currentByResourceId/' + resourceId, () => {
|
||||
this.toPage(uri);
|
||||
});
|
||||
},
|
||||
toPage(uri) {
|
||||
let id = "new_a";
|
||||
let a = document.createElement("a");
|
||||
a.setAttribute("href", uri);
|
||||
a.setAttribute("target", "_blank");
|
||||
a.setAttribute("id", id);
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
|
||||
let element = document.getElementById(id);
|
||||
element.parentNode.removeChild(element);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -110,3 +110,54 @@ export function getResource(d) {
|
|||
}
|
||||
return resourceType;
|
||||
}
|
||||
|
||||
export function getUrl(d) {
|
||||
let url = "/#";
|
||||
switch (d.resourceType) {
|
||||
case "JENKINS_TASK" :
|
||||
url += "/track/plan/all";
|
||||
break;
|
||||
case "TEST_PLAN_TASK" :
|
||||
url += "/track/plan/all";
|
||||
break;
|
||||
case "REVIEW_TASK" :
|
||||
url += "/track/review/all";
|
||||
break;
|
||||
case "DEFECT_TASK" :
|
||||
url += "/track/issue";
|
||||
break;
|
||||
case "SWAGGER_TASK" :
|
||||
url += "/api/definition";
|
||||
break;
|
||||
case "API_AUTOMATION_TASK" :
|
||||
url += "/api/automation";
|
||||
break;
|
||||
case "API_DEFINITION_TASK" :
|
||||
url += "/api/definition";
|
||||
break;
|
||||
case "API_HOME_TASK" :
|
||||
url += "/api/home";
|
||||
break;
|
||||
case "API_REPORT_TASK" :
|
||||
url += "/api/automation/report";
|
||||
break;
|
||||
case "PERFORMANCE_REPORT_TASK" :
|
||||
url += "/performance/report/all";
|
||||
break;
|
||||
case "PERFORMANCE_TEST_TASK" :
|
||||
url += "/performance/test/all";
|
||||
break;
|
||||
case "TRACK_TEST_CASE_TASK" :
|
||||
url += "/track/case/all";
|
||||
break;
|
||||
case "TRACK_HOME_TASK" :
|
||||
url += "/track/home";
|
||||
break;
|
||||
case "TRACK_REPORT_TASK" :
|
||||
url += "/track/testPlan/reportList";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue