fix(接口测试): 优化接口场景和UI共用的报告头组件中跳转数据方法

优化接口场景和UI共用的报告头组件中跳转数据方法
This commit is contained in:
song-tianyang 2023-02-01 18:21:28 +08:00 committed by 建国
parent 43c23773a8
commit a80199cfe6
5 changed files with 25 additions and 28 deletions

View File

@ -49,4 +49,6 @@ public interface ExtProjectMapper {
List<String> getThirdPartProjectIds();
ProjectDTO getProjectByScenario(String scenarioId);
ProjectDTO getProjectByUi(String id);
}

View File

@ -439,4 +439,13 @@
INNER join api_scenario a on a.project_id = p.id
where a.id = #{scenarioId}
</select>
<select id="getProjectByUi" resultType="io.metersphere.dto.ProjectDTO">
SELECT p.* , w.name as workspaceName
from project p
INNER JOIN workspace w on p.workspace_id = w.id
INNER join ui_scenario a on a.project_id = p.id
where a.id = #{scenarioId}
</select>
</mapper>

View File

@ -166,7 +166,7 @@ public class ProjectController {
}
@GetMapping("/api/project/get/{id}")
public ProjectDTO getProjectByScenario(@PathVariable String id) {
return projectService.getProjectByScenario(id);
public ProjectDTO getProjectByScenarioOrUi(@PathVariable String id) {
return projectService.getProjectByScenarioOrUi(id);
}
}

View File

@ -1083,7 +1083,11 @@ public class ProjectService {
}
}
public ProjectDTO getProjectByScenario(String id) {
return extProjectMapper.getProjectByScenario(id);
public ProjectDTO getProjectByScenarioOrUi(String id) {
ProjectDTO project = extProjectMapper.getProjectByScenario(id);
if(project == null){
project = extProjectMapper.getProjectByUi(id);
}
return project;
}
}

View File

@ -136,34 +136,16 @@ export default {
},
clickResource() {
// UI
if(this.isUi){
this.clickUiResource();
}else {
this.clickScenarioResource();
}
},
clickUiResource(){
let workspaceId = getCurrentWorkspaceId();
if (this.report.projectId !== getCurrentProjectID()) {
this.$get("/project/get/" + this.report.projectId, response => {
if (response.data) {
workspaceId = response.data.workspaceId;
this.checkPermission(workspaceId, this.report.projectId, response.data.name);
}
});
} else {
this.checkPermission(workspaceId, this.report.projectId, null);
}
},
clickScenarioResource(){
let workspaceId = getCurrentWorkspaceId();
this.$get("/project/api/project/get/" + this.scenarioId, res => {
let scenarioProjectId = res.data.id;
if (scenarioProjectId !== getCurrentProjectID()) {
if(res.data){
let scenarioProjectId = res.data.id;
if (scenarioProjectId !== getCurrentProjectID()) {
workspaceId = res.data.workspaceId;
this.checkPermission(workspaceId, scenarioProjectId, res.data.name);
} else {
this.checkPermission(workspaceId, scenarioProjectId, null);
} else {
this.checkPermission(workspaceId, scenarioProjectId, null);
}
}
});
},