refactor: 优化插件获取缺陷接口

This commit is contained in:
chenjianxing 2022-12-12 21:26:39 +08:00 committed by jianxing
parent 893de5af32
commit 0aac4ed341
5 changed files with 62 additions and 14 deletions

View File

@ -210,6 +210,11 @@ public class IssuesController {
return issuesService.getPlatformTransitions(request);
}
@PostMapping("/platform/status")
public List<PlatformStatusDTO> getPlatformStatus(@RequestBody PlatformIssueTypeRequest request) {
return issuesService.getPlatformStatus(request);
}
@GetMapping("/platform/option")
public List<SelectOption> getPlatformOptions() {
return platformPluginService.getPlatformOptions();

View File

@ -1449,16 +1449,45 @@ public class IssuesService {
return extIssuesMapper.getIssues(request);
}
public List<PlatformStatusDTO> getPlatformStatus(PlatformIssueTypeRequest request) {
List<PlatformStatusDTO> platformStatusDTOS = new ArrayList<>();
Project project = baseProjectService.getProjectById(request.getProjectId());
String projectConfig = PlatformPluginService.getCompatibleProjectConfig(project);
String platform = project.getPlatform();
if (PlatformPluginService.isPluginPlatform(platform)) {
return platformPluginService.getPlatform(platform)
.getStatusList(projectConfig)
.stream().map(item -> {
// 全部插件化后简化
PlatformStatusDTO platformStatusDTO = new PlatformStatusDTO();
platformStatusDTO.setLabel(item.getLabel());
platformStatusDTO.setValue(item.getValue());
return platformStatusDTO;
})
.collect(Collectors.toList());
} else {
List<String> platforms = getPlatforms(project);
if (CollectionUtils.isEmpty(platforms)) {
return platformStatusDTOS;
}
IssuesRequest issuesRequest = getDefaultIssueRequest(request.getProjectId(), request.getWorkspaceId());
return IssueFactory.createPlatform(platform, issuesRequest).getTransitions(request.getPlatformKey());
}
}
public List<PlatformStatusDTO> getPlatformTransitions(PlatformIssueTypeRequest request) {
List<PlatformStatusDTO> platformStatusDTOS = new ArrayList<>();
if (!StringUtils.isBlank(request.getPlatformKey())) {
Project project = baseProjectService.getProjectById(request.getProjectId());
String projectConfig = PlatformPluginService.getCompatibleProjectConfig(project);
String platform = project.getPlatform();
if (PlatformPluginService.isPluginPlatform(platform)) {
return platformPluginService.getPlatform(platform)
.getStatusList(request.getPlatformKey())
.getTransitions(projectConfig, request.getPlatformKey())
.stream().map(item -> {
// 全部插件化后简化
PlatformStatusDTO platformStatusDTO = new PlatformStatusDTO();
platformStatusDTO.setLabel(item.getLabel());
platformStatusDTO.setValue(item.getValue());

View File

@ -212,6 +212,10 @@ export function getPlatformStatus(param) {
return post('/issues/platform/status', param);
}
export function getPlatformTransitions(param) {
return post('/issues/platform/transitions', param);
}
export function enableThirdPartTemplate(projectId) {
return get(BASE_URL + 'third/part/template/enable/' + projectId);
}

View File

@ -200,13 +200,11 @@ import {hasLicense} from "metersphere-frontend/src/utils/permission";
import {
enableThirdPartTemplate,
getIssuePartTemplateWithProject,
getPlatformStatus,
getIssuesById,
saveOrUpdateIssue,
saveFollow,
getFollow,
getComments,
getTapdUser
getTapdUser, getPlatformTransitions
} from "@/api/issue";
import {
uploadIssueAttachment,
@ -433,7 +431,7 @@ export default {
projectId: getCurrentProjectID(),
workspaceId: getCurrentWorkspaceId()
}
getPlatformStatus(data).then(response => {
getPlatformTransitions(data).then(response => {
if (response.data.length > 0) {
this.platformTransitions = response.data;
}

View File

@ -65,15 +65,14 @@
<template v-slot="scope">
<span v-if="item.id === 'platformStatus'">
<span v-if="scope.row.platform ==='Zentao'">
{{
scope.row.platformStatus ? issueStatusMap[scope.row.platformStatus] : '--'
}}
<span v-if="scope.row.platform === 'Tapd'">
{{ scope.row.platformStatus ? tapdIssueStatusMap[scope.row.platformStatus] : '--' }}
</span>
<span
v-else-if="scope.row.platform ==='Tapd'">{{
scope.row.platformStatus ? tapdIssueStatusMap[scope.row.platformStatus] : '--'
}}
<span v-else-if="scope.row.platform ==='Local'">
{{ scope.row.platformStatus ? tapdIssueStatusMap[scope.row.platformStatus] : '--' }}
</span>
<span v-else-if="platformStatusMap && platformStatusMap.get(scope.row.platformStatus)">
{{ platformStatusMap.get(scope.row.platformStatus) }}
</span>
<span v-else>
{{ scope.row.platformStatus ? scope.row.platformStatus : '--' }}
@ -161,7 +160,7 @@ import {
getIssues,
syncIssues,
deleteIssue,
getIssuesById, batchDeleteIssue, getPlatformOption, syncAllIssues
getIssuesById, batchDeleteIssue, getPlatformOption, syncAllIssues, getPlatformStatus
} from "@/api/issue";
import {
getCustomFieldValue,
@ -240,6 +239,8 @@ export default {
loading: false,
dataSelectRange: "",
platformOptions: [],
platformStatus: [],
platformStatusMap: new Map(),
hasLicense: false,
columns: {
num: {
@ -303,6 +304,17 @@ export default {
});
this.hasLicense = hasLicense();
getPlatformStatus( {
projectId: getCurrentProjectID(),
workspaceId: getCurrentWorkspaceId()
}).then((r) => {
this.platformStatus = r.data;
this.platformStatusMap = new Map();
this.platformStatus.forEach(item => {
this.platformStatusMap.set(item.value, item.label);
});
});
},
computed: {
platformFilters() {