From 628897b46220521a0fa572f5eddc4f847a2b6e37 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Fri, 18 Nov 2022 10:54:15 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E7=BC=BA=E9=99=B7=E7=AE=A1=E7=90=86=E6=8F=92=E4=BB=B6=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../remote/SystemSettingController.java | 2 +- .../remote/service/SystemSettingService.java | 12 - .../menu/template/IssueTemplateEdit.vue | 7 +- .../menu/template/IssuesTemplateList.vue | 18 +- system-setting/backend/pom.xml | 6 + .../controller/PlatformPluginController.java | 2 +- .../service/PlatformPluginService.java | 10 +- .../service/plugin/MinioStorageStrategy.java | 2 +- .../metersphere/utils/PluginManagerUtil.java | 2 +- .../controller/IssuesController.java | 14 +- .../excel/listener/IssueExcelListener.java | 10 +- .../service/AttachmentService.java | 97 ++-- .../io/metersphere/service/IssuesService.java | 435 +++++++++++++----- .../service/PlatformPluginService.java | 59 ++- .../issue/platform/AbstractIssuePlatform.java | 15 +- .../service/issue/platform/IssueFactory.java | 13 - .../service/issue/platform/LocalPlatform.java | 16 +- .../service/plugin/MinioStorageStrategy.java | 2 +- .../wapper/IssueProxyResourceService.java | 8 +- .../service/wapper/UserService.java | 5 + .../metersphere/utils/PluginManagerUtil.java | 2 +- test-track/frontend/src/api/issue.js | 35 +- .../src/business/issue/IssueEditDetail.vue | 182 ++++---- 24 files changed, 638 insertions(+), 318 deletions(-) delete mode 100644 project-management/backend/src/main/java/io/metersphere/remote/service/SystemSettingService.java diff --git a/pom.xml b/pom.xml index ab661aa96d..b06296a1de 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ 2021.0.5 5.7.5 2.7.15 - main + 1.0.0 7.15.0 1.10.0 7.4.1.jre8 diff --git a/project-management/backend/src/main/java/io/metersphere/controller/remote/SystemSettingController.java b/project-management/backend/src/main/java/io/metersphere/controller/remote/SystemSettingController.java index 37fd79a3a5..c7b1244cee 100644 --- a/project-management/backend/src/main/java/io/metersphere/controller/remote/SystemSettingController.java +++ b/project-management/backend/src/main/java/io/metersphere/controller/remote/SystemSettingController.java @@ -1,7 +1,7 @@ package io.metersphere.controller.remote; import io.metersphere.remote.service.PlatformPluginService; -import io.metersphere.remote.service.SystemSettingService; +import io.metersphere.service.remote.SystemSettingService; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; diff --git a/project-management/backend/src/main/java/io/metersphere/remote/service/SystemSettingService.java b/project-management/backend/src/main/java/io/metersphere/remote/service/SystemSettingService.java deleted file mode 100644 index 5783f6b10c..0000000000 --- a/project-management/backend/src/main/java/io/metersphere/remote/service/SystemSettingService.java +++ /dev/null @@ -1,12 +0,0 @@ -package io.metersphere.remote.service; - -import io.metersphere.commons.constants.MicroServiceName; -import io.metersphere.service.RemoteService; -import org.springframework.stereotype.Service; - -@Service -public class SystemSettingService extends RemoteService { - public SystemSettingService() { - super(MicroServiceName.SYSTEM_SETTING); - } -} diff --git a/project-management/frontend/src/business/menu/template/IssueTemplateEdit.vue b/project-management/frontend/src/business/menu/template/IssueTemplateEdit.vue index fd379b2dd8..bbd343ed52 100644 --- a/project-management/frontend/src/business/menu/template/IssueTemplateEdit.vue +++ b/project-management/frontend/src/business/menu/template/IssueTemplateEdit.vue @@ -49,7 +49,6 @@ import draggable from 'vuedraggable'; import TemplateComponentEditHeader from "./ext/TemplateComponentEditHeader"; import MsFormDivider from "metersphere-frontend/src/components/MsFormDivider"; -import {ISSUE_PLATFORM_OPTION} from "metersphere-frontend/src/utils/table-constants"; import CustomFieldFormList from "./CustomFieldFormList"; import CustomFieldRelateList from "./CustomFieldRelateList"; import FieldTemplateEdit from "./FieldTemplateEdit"; @@ -90,10 +89,10 @@ export default { url: '', }; }, + props: { + platformOption: Array + }, computed: { - platformOption() { - return ISSUE_PLATFORM_OPTION; - }, isSystem() { return this.form.system; } diff --git a/project-management/frontend/src/business/menu/template/IssuesTemplateList.vue b/project-management/frontend/src/business/menu/template/IssuesTemplateList.vue index a412422919..836c0f87cb 100644 --- a/project-management/frontend/src/business/menu/template/IssuesTemplateList.vue +++ b/project-management/frontend/src/business/menu/template/IssuesTemplateList.vue @@ -76,7 +76,7 @@ :total="total"/> - + @@ -95,6 +95,7 @@ import IssueTemplateEdit from "./IssueTemplateEdit"; import {deleteIssueFieldTemplateById, getIssueFieldTemplatePages} from "../../../api/template"; import MsDeleteConfirm from "metersphere-frontend/src/components/MsDeleteConfirm"; import IssueTemplateCopy from "./IssueTemplateCopy"; +import {getPlatformOption} from "@/api/platform-plugin"; export default { name: "IssuesTemplateList", @@ -102,7 +103,7 @@ export default { IssueTemplateEdit, IssueTemplateCopy, MsTableHeader, - MsTablePagination, MsTableButton, MsTableOperators, MsTableColumn, MsTable , MsDeleteConfirm + MsTablePagination, MsTableButton, MsTableOperators, MsTableColumn, MsTable, MsDeleteConfirm }, data() { return { @@ -113,9 +114,9 @@ export default { currentPage: 1, result: {}, loading: false, + platformOptions: [], issuePlatformMap: { Local: 'Metersphere', - Jira: 'JIRA', Tapd: 'Tapd', Zentao: '禅道', AzureDevops: 'Azure Devops', @@ -135,6 +136,10 @@ export default { }; }, created() { + getPlatformOption() + .then((r) => { + this.platformOptions = r.data; + }); this.initTableData(); }, computed: { @@ -142,7 +147,12 @@ export default { return ISSUE_TEMPLATE_LIST; }, platformFilters() { - return ISSUE_PLATFORM_OPTION; + this.platformOptions.forEach(item => { + this.issuePlatformMap[item.value] = item.text; + }); + let options = [...ISSUE_PLATFORM_OPTION]; + options.push(...this.platformOptions); + return options; }, tableHeight() { return document.documentElement.clientHeight - 200; diff --git a/system-setting/backend/pom.xml b/system-setting/backend/pom.xml index e905bdaba8..b16473887e 100644 --- a/system-setting/backend/pom.xml +++ b/system-setting/backend/pom.xml @@ -26,6 +26,12 @@ metersphere-platform-plugin-sdk io.metersphere ${platform-plugin-sdk.version} + + + io.metersphere + domain + + diff --git a/system-setting/backend/src/main/java/io/metersphere/controller/PlatformPluginController.java b/system-setting/backend/src/main/java/io/metersphere/controller/PlatformPluginController.java index ede7c8cf29..01b4f39eef 100644 --- a/system-setting/backend/src/main/java/io/metersphere/controller/PlatformPluginController.java +++ b/system-setting/backend/src/main/java/io/metersphere/controller/PlatformPluginController.java @@ -1,6 +1,6 @@ package io.metersphere.controller; -import io.metersphere.domain.SelectOption; +import io.metersphere.platform.domain.SelectOption; import io.metersphere.dto.PlatformProjectOptionRequest; import io.metersphere.service.PlatformPluginService; import org.springframework.web.bind.annotation.*; diff --git a/system-setting/backend/src/main/java/io/metersphere/service/PlatformPluginService.java b/system-setting/backend/src/main/java/io/metersphere/service/PlatformPluginService.java index 275fff22f7..28c91de908 100644 --- a/system-setting/backend/src/main/java/io/metersphere/service/PlatformPluginService.java +++ b/system-setting/backend/src/main/java/io/metersphere/service/PlatformPluginService.java @@ -1,7 +1,7 @@ package io.metersphere.service; -import io.metersphere.api.Platform; -import io.metersphere.api.PluginMetaInfo; +import io.metersphere.platform.api.Platform; +import io.metersphere.platform.api.PluginMetaInfo; import io.metersphere.base.domain.PluginWithBLOBs; import io.metersphere.base.domain.ServiceIntegration; import io.metersphere.base.mapper.PluginMapper; @@ -11,11 +11,9 @@ import io.metersphere.commons.utils.BeanUtils; import io.metersphere.commons.utils.JSON; import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.SessionUtils; -import io.metersphere.domain.GetOptionRequest; -import io.metersphere.domain.PlatformRequest; -import io.metersphere.domain.SelectOption; +import io.metersphere.platform.domain.*; import io.metersphere.dto.PlatformProjectOptionRequest; -import io.metersphere.loader.PlatformPluginManager; +import io.metersphere.platform.loader.PlatformPluginManager; import io.metersphere.request.IntegrationRequest; import io.metersphere.utils.PluginManagerUtil; import org.apache.commons.lang3.StringUtils; diff --git a/system-setting/backend/src/main/java/io/metersphere/service/plugin/MinioStorageStrategy.java b/system-setting/backend/src/main/java/io/metersphere/service/plugin/MinioStorageStrategy.java index 41e0d9a8aa..a18977353e 100644 --- a/system-setting/backend/src/main/java/io/metersphere/service/plugin/MinioStorageStrategy.java +++ b/system-setting/backend/src/main/java/io/metersphere/service/plugin/MinioStorageStrategy.java @@ -1,6 +1,6 @@ package io.metersphere.service.plugin; -import im.metersphere.storage.StorageStrategy; +import im.metersphere.plugin.storage.StorageStrategy; import io.metersphere.commons.constants.StorageConstants; import io.metersphere.commons.utils.CommonBeanFactory; import io.metersphere.metadata.service.FileManagerService; diff --git a/system-setting/backend/src/main/java/io/metersphere/utils/PluginManagerUtil.java b/system-setting/backend/src/main/java/io/metersphere/utils/PluginManagerUtil.java index e529259fde..95e7d2b796 100644 --- a/system-setting/backend/src/main/java/io/metersphere/utils/PluginManagerUtil.java +++ b/system-setting/backend/src/main/java/io/metersphere/utils/PluginManagerUtil.java @@ -1,6 +1,6 @@ package io.metersphere.utils; -import im.metersphere.loader.PluginManager; +import im.metersphere.plugin.loader.PluginManager; import io.metersphere.base.domain.PluginWithBLOBs; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.LogUtil; diff --git a/test-track/backend/src/main/java/io/metersphere/controller/IssuesController.java b/test-track/backend/src/main/java/io/metersphere/controller/IssuesController.java index f0630db949..70beaa4505 100644 --- a/test-track/backend/src/main/java/io/metersphere/controller/IssuesController.java +++ b/test-track/backend/src/main/java/io/metersphere/controller/IssuesController.java @@ -17,13 +17,11 @@ import io.metersphere.log.annotation.MsAuditLog; import io.metersphere.notice.annotation.SendNotice; import io.metersphere.request.issues.IssueExportRequest; import io.metersphere.request.issues.IssueImportRequest; -import io.metersphere.request.issues.JiraIssueTypeRequest; import io.metersphere.request.issues.PlatformIssueTypeRequest; import io.metersphere.request.testcase.AuthUserIssueRequest; import io.metersphere.request.testcase.IssuesCountRequest; import io.metersphere.service.BaseCheckPermissionService; import io.metersphere.service.IssuesService; -import io.metersphere.service.issue.domain.jira.JiraIssueType; import io.metersphere.service.issue.domain.zentao.ZentaoBuild; import io.metersphere.xpack.track.dto.*; import io.metersphere.xpack.track.dto.request.IssuesRequest; @@ -186,14 +184,14 @@ public class IssuesController { return issuesService.getThirdPartTemplate(projectId); } - @PostMapping("/jira/issuetype") - public List getJiraIssueType(@RequestBody JiraIssueTypeRequest request) { - return issuesService.getIssueTypes(request); + @GetMapping("/demand/list/{projectId}") + public List getDemandList(@PathVariable String projectId) { + return issuesService.getDemandList(projectId); } - @GetMapping("/demand/list/{projectId}") - public List getDemandList(@PathVariable String projectId) { - return issuesService.getDemandList(projectId); + @GetMapping("/third/part/template/enable/{projectId}") + public boolean thirdPartTemplateEnable(@PathVariable String projectId) { + return issuesService.thirdPartTemplateEnable(projectId); } @PostMapping("/platform/transitions") diff --git a/test-track/backend/src/main/java/io/metersphere/excel/listener/IssueExcelListener.java b/test-track/backend/src/main/java/io/metersphere/excel/listener/IssueExcelListener.java index c739ed0db9..57579dee6d 100644 --- a/test-track/backend/src/main/java/io/metersphere/excel/listener/IssueExcelListener.java +++ b/test-track/backend/src/main/java/io/metersphere/excel/listener/IssueExcelListener.java @@ -295,14 +295,14 @@ public class IssueExcelListener extends AnalysisEventListener> customFieldMap = customFields.stream().collect(Collectors.groupingBy(CustomFieldDao::getName)); issueExcelData.getCustomData().forEach((k, v) -> { try { - List customFieldDaos = customFieldMap.get(k); - if (CollectionUtils.isNotEmpty(customFieldDaos) && customFieldDaos.size() > 0) { - CustomFieldDao customFieldDao = customFieldDaos.get(0); + List customFieldDaoList = customFieldMap.get(k); + if (CollectionUtils.isNotEmpty(customFieldDaoList) && customFieldDaoList.size() > 0) { + CustomFieldDao customFieldDao = customFieldDaoList.get(0); String type = customFieldDao.getType(); - // addfield + // add field CustomFieldResourceDTO customFieldResourceDTO = new CustomFieldResourceDTO(); customFieldResourceDTO.setFieldId(customFieldDao.getId()); - // requestfield + // request field CustomFieldItemDTO customFieldItemDTO = new CustomFieldItemDTO(); BeanUtils.copyBean(customFieldItemDTO, customFieldDao); if (StringUtils.isEmpty(v.toString())) { diff --git a/test-track/backend/src/main/java/io/metersphere/service/AttachmentService.java b/test-track/backend/src/main/java/io/metersphere/service/AttachmentService.java index 8da7bfa73d..f64d8ec27c 100644 --- a/test-track/backend/src/main/java/io/metersphere/service/AttachmentService.java +++ b/test-track/backend/src/main/java/io/metersphere/service/AttachmentService.java @@ -8,16 +8,17 @@ import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.BeanUtils; import io.metersphere.commons.utils.FileUtils; import io.metersphere.commons.utils.SessionUtils; -import io.metersphere.xpack.track.dto.AttachmentSyncType; import io.metersphere.constants.AttachmentType; import io.metersphere.i18n.Translator; import io.metersphere.metadata.service.FileMetadataService; import io.metersphere.metadata.utils.MetadataUtils; +import io.metersphere.platform.domain.SyncIssuesAttachmentRequest; import io.metersphere.request.attachment.AttachmentRequest; -import io.metersphere.xpack.track.dto.request.IssuesRequest; -import io.metersphere.xpack.track.dto.request.IssuesUpdateRequest; import io.metersphere.service.issue.platform.IssueFactory; import io.metersphere.xmind.utils.FileUtil; +import io.metersphere.xpack.track.dto.AttachmentSyncType; +import io.metersphere.xpack.track.dto.request.IssuesRequest; +import io.metersphere.xpack.track.dto.request.IssuesUpdateRequest; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.ibatis.session.ExecutorType; @@ -35,7 +36,7 @@ import javax.annotation.Resource; import java.io.*; import java.util.*; import java.util.stream.Collectors; -import java.util.stream.Stream; + /** * @author songcc @@ -68,6 +69,8 @@ public class AttachmentService { private BaseUserService baseUserService; @Resource SqlSessionFactory sqlSessionFactory; + @Resource + PlatformPluginService platformPluginService; public void uploadAttachment(AttachmentRequest request, MultipartFile file) { // 附件上传的前置校验 @@ -98,11 +101,16 @@ public class AttachmentService { IssuesUpdateRequest updateRequest = new IssuesUpdateRequest(); updateRequest.setPlatformId(issues.getPlatformId()); File uploadFile = new File(fileAttachmentMetadata.getFilePath() + "/" + fileAttachmentMetadata.getName()); - IssuesRequest issuesRequest = new IssuesRequest(); - issuesRequest.setWorkspaceId(SessionUtils.getCurrentWorkspaceId()); - issuesRequest.setProjectId(SessionUtils.getCurrentProjectId()); - Objects.requireNonNull(IssueFactory.createPlatform(issues.getPlatform(), issuesRequest)) - .syncIssuesAttachment(updateRequest, uploadFile, AttachmentSyncType.UPLOAD); + + if (PlatformPluginService.isPluginPlatform(issues.getPlatform())) { + syncIssuesAttachment(issues, uploadFile, AttachmentSyncType.UPLOAD); + } else { + IssuesRequest issuesRequest = new IssuesRequest(); + issuesRequest.setWorkspaceId(SessionUtils.getCurrentWorkspaceId()); + issuesRequest.setProjectId(SessionUtils.getCurrentProjectId()); + Objects.requireNonNull(IssueFactory.createPlatform(issues.getPlatform(), issuesRequest)) + .syncIssuesAttachment(updateRequest, uploadFile, AttachmentSyncType.UPLOAD); + } } } @@ -119,11 +127,16 @@ public class AttachmentService { IssuesUpdateRequest updateRequest = new IssuesUpdateRequest(); updateRequest.setPlatformId(issues.getPlatformId()); File deleteFile = new File(fileAttachmentMetadata.getFilePath() + "/" + fileAttachmentMetadata.getName()); - IssuesRequest issuesRequest = new IssuesRequest(); - issuesRequest.setWorkspaceId(SessionUtils.getCurrentWorkspaceId()); - issuesRequest.setProjectId(SessionUtils.getCurrentProjectId()); - Objects.requireNonNull(IssueFactory.createPlatform(issues.getPlatform(), issuesRequest)) - .syncIssuesAttachment(updateRequest, deleteFile, AttachmentSyncType.DELETE); + + if (PlatformPluginService.isPluginPlatform(issues.getPlatform())) { + syncIssuesAttachment(issues, deleteFile, AttachmentSyncType.DELETE); + } else { + IssuesRequest issuesRequest = new IssuesRequest(); + issuesRequest.setWorkspaceId(SessionUtils.getCurrentWorkspaceId()); + issuesRequest.setProjectId(SessionUtils.getCurrentProjectId()); + Objects.requireNonNull(IssueFactory.createPlatform(issues.getPlatform(), issuesRequest)) + .syncIssuesAttachment(updateRequest, deleteFile, AttachmentSyncType.DELETE); + } } } @@ -178,17 +191,31 @@ public class AttachmentService { IssuesUpdateRequest updateRequest = new IssuesUpdateRequest(); updateRequest.setPlatformId(issues.getPlatformId()); File refFile = downloadMetadataFile(metadataRefId, fileMetadata.getName()); - IssuesRequest issuesRequest = new IssuesRequest(); - issuesRequest.setWorkspaceId(SessionUtils.getCurrentWorkspaceId()); - issuesRequest.setProjectId(SessionUtils.getCurrentProjectId()); - Objects.requireNonNull(IssueFactory.createPlatform(issues.getPlatform(), issuesRequest)) - .syncIssuesAttachment(updateRequest, refFile, AttachmentSyncType.UPLOAD); + + if (PlatformPluginService.isPluginPlatform(issues.getPlatform())) { + syncIssuesAttachment(issues, refFile, AttachmentSyncType.UPLOAD); + } else { + IssuesRequest issuesRequest = new IssuesRequest(); + issuesRequest.setWorkspaceId(SessionUtils.getCurrentWorkspaceId()); + issuesRequest.setProjectId(SessionUtils.getCurrentProjectId()); + Objects.requireNonNull(IssueFactory.createPlatform(issues.getPlatform(), issuesRequest)) + .syncIssuesAttachment(updateRequest, refFile, AttachmentSyncType.UPLOAD); + } FileUtils.deleteFile(FileUtils.ATTACHMENT_TMP_DIR + File.separator + fileMetadata.getName()); } }); } } + public void syncIssuesAttachment(IssuesWithBLOBs issues, File refFile, AttachmentSyncType attachmentSyncType) { + SyncIssuesAttachmentRequest attachmentRequest = new SyncIssuesAttachmentRequest(); + attachmentRequest.setPlatformId(issues.getPlatformId()); + attachmentRequest.setFile(refFile); + attachmentRequest.setSyncType(attachmentSyncType.syncOperateType()); + platformPluginService.getPlatform(issues.getPlatform()) + .syncIssuesAttachment(attachmentRequest); + } + public List listMetadata(AttachmentRequest request) { List attachments = new ArrayList(); AttachmentModuleRelationExample example = new AttachmentModuleRelationExample(); @@ -276,12 +303,17 @@ public class AttachmentService { IssuesUpdateRequest updateRequest = new IssuesUpdateRequest(); updateRequest.setPlatformId(issues.getPlatformId()); File refFile = downloadMetadataFile(metadataRefId, fileMetadata.getName()); - IssuesRequest issuesRequest = new IssuesRequest(); - issuesRequest.setWorkspaceId(SessionUtils.getCurrentWorkspaceId()); - issuesRequest.setProjectId(SessionUtils.getCurrentProjectId()); - Objects.requireNonNull(IssueFactory.createPlatform(issues.getPlatform(), issuesRequest)) - .syncIssuesAttachment(updateRequest, refFile, AttachmentSyncType.UPLOAD); - FileUtils.deleteFile(FileUtils.ATTACHMENT_TMP_DIR + File.separator + fileMetadata.getName()); + + if (PlatformPluginService.isPluginPlatform(issues.getPlatform())) { + syncIssuesAttachment(issues, refFile, AttachmentSyncType.UPLOAD); + } else { + IssuesRequest issuesRequest = new IssuesRequest(); + issuesRequest.setWorkspaceId(SessionUtils.getCurrentWorkspaceId()); + issuesRequest.setProjectId(SessionUtils.getCurrentProjectId()); + Objects.requireNonNull(IssueFactory.createPlatform(issues.getPlatform(), issuesRequest)) + .syncIssuesAttachment(updateRequest, refFile, AttachmentSyncType.UPLOAD); + FileUtils.deleteFile(FileUtils.ATTACHMENT_TMP_DIR + File.separator + fileMetadata.getName()); + } } }); sqlSession.flushStatements(); @@ -301,11 +333,16 @@ public class AttachmentService { IssuesUpdateRequest updateRequest = new IssuesUpdateRequest(); updateRequest.setPlatformId(issues.getPlatformId()); File deleteFile = new File(FileUtils.ATTACHMENT_TMP_DIR + File.separator + fileAttachmentMetadata.getName()); - IssuesRequest issuesRequest = new IssuesRequest(); - issuesRequest.setWorkspaceId(SessionUtils.getCurrentWorkspaceId()); - issuesRequest.setProjectId(SessionUtils.getCurrentProjectId()); - Objects.requireNonNull(IssueFactory.createPlatform(issues.getPlatform(), issuesRequest)) - .syncIssuesAttachment(updateRequest, deleteFile, AttachmentSyncType.DELETE); + + if (PlatformPluginService.isPluginPlatform(issues.getPlatform())) { + syncIssuesAttachment(issues, deleteFile, AttachmentSyncType.UPLOAD); + } else { + IssuesRequest issuesRequest = new IssuesRequest(); + issuesRequest.setWorkspaceId(SessionUtils.getCurrentWorkspaceId()); + issuesRequest.setProjectId(SessionUtils.getCurrentProjectId()); + Objects.requireNonNull(IssueFactory.createPlatform(issues.getPlatform(), issuesRequest)) + .syncIssuesAttachment(updateRequest, deleteFile, AttachmentSyncType.DELETE); + } }); } AttachmentModuleRelationExample example = new AttachmentModuleRelationExample(); diff --git a/test-track/backend/src/main/java/io/metersphere/service/IssuesService.java b/test-track/backend/src/main/java/io/metersphere/service/IssuesService.java index 887a220eca..a60fc8c691 100644 --- a/test-track/backend/src/main/java/io/metersphere/service/IssuesService.java +++ b/test-track/backend/src/main/java/io/metersphere/service/IssuesService.java @@ -4,6 +4,7 @@ import com.alibaba.excel.EasyExcelFactory; import com.alibaba.excel.util.DateUtils; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; +import io.metersphere.platform.api.Platform; import io.metersphere.base.domain.*; import io.metersphere.base.mapper.*; import io.metersphere.base.mapper.ext.ExtIssueCommentMapper; @@ -13,6 +14,7 @@ import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.*; import io.metersphere.constants.AttachmentType; import io.metersphere.constants.SystemCustomField; +import io.metersphere.platform.domain.*; import io.metersphere.dto.*; import io.metersphere.excel.constants.IssueExportHeadField; import io.metersphere.excel.domain.ExcelErrData; @@ -37,17 +39,18 @@ import io.metersphere.request.IntegrationRequest; import io.metersphere.request.attachment.AttachmentRequest; import io.metersphere.request.issues.IssueExportRequest; import io.metersphere.request.issues.IssueImportRequest; -import io.metersphere.request.issues.JiraIssueTypeRequest; import io.metersphere.request.issues.PlatformIssueTypeRequest; import io.metersphere.request.testcase.AuthUserIssueRequest; import io.metersphere.request.testcase.IssuesCountRequest; -import io.metersphere.service.issue.domain.jira.JiraIssueType; import io.metersphere.service.issue.domain.zentao.ZentaoBuild; import io.metersphere.service.issue.platform.*; import io.metersphere.service.remote.project.TrackCustomFieldTemplateService; import io.metersphere.service.remote.project.TrackIssueTemplateService; import io.metersphere.service.wapper.TrackProjectService; +import io.metersphere.service.wapper.UserService; import io.metersphere.utils.DistinctKeyUtil; +import io.metersphere.xpack.track.dto.PlatformStatusDTO; +import io.metersphere.xpack.track.dto.PlatformUser; import io.metersphere.xpack.track.dto.*; import io.metersphere.xpack.track.dto.request.IssuesRequest; import io.metersphere.xpack.track.dto.request.IssuesUpdateRequest; @@ -124,6 +127,8 @@ public class IssuesService { @Resource private AttachmentService attachmentService; @Resource + private AttachmentModuleRelationMapper attachmentModuleRelationMapper; + @Resource private ProjectMapper projectMapper; @Resource SqlSessionFactory sqlSessionFactory; @@ -131,6 +136,10 @@ public class IssuesService { private FileMetadataMapper fileMetadataMapper; @Resource private ExtIssueCommentMapper extIssueCommentMapper; + @Resource + private PlatformPluginService platformPluginService; + @Resource + private UserService userService; private static final String SYNC_THIRD_PARTY_ISSUES_KEY = "ISSUE:SYNC"; @@ -143,19 +152,56 @@ public class IssuesService { public IssuesWithBLOBs addIssues(IssuesUpdateRequest issuesRequest, List files) { - List platformList = getAddPlatforms(issuesRequest); + Project project = baseProjectService.getProjectById(issuesRequest.getProjectId()); IssuesWithBLOBs issues = null; - for (IssuesPlatform platform : platformList) { - issues = platform.addIssue(issuesRequest); + if (PlatformPluginService.isPluginPlatform(project.getPlatform())) { + PlatformIssuesUpdateRequest platformIssuesUpdateRequest = + JSON.parseObject(JSON.toJSONString(issuesRequest), PlatformIssuesUpdateRequest.class); + List customFieldItemDTOS = + JSON.parseArray(JSON.toJSONString(issuesRequest.getRequestFields()), PlatformCustomFieldItemDTO.class); + platformIssuesUpdateRequest.setCustomFieldList(customFieldItemDTOS); // todo 全部插件化后去掉 + platformIssuesUpdateRequest.setUserPlatformUserConfig(userService.getCurrentPlatformInfoStr(SessionUtils.getCurrentWorkspaceId())); + platformIssuesUpdateRequest.setProjectConfig(PlatformPluginService.getCompatibleProjectConfig(project)); + + issues = platformPluginService.getPlatform(project.getPlatform()) + .addIssue(platformIssuesUpdateRequest); + + insertIssues(issues); + issuesRequest.setId(issues.getId()); + + // 用例与第三方缺陷平台中的缺陷关联 + handleTestCaseIssues(issuesRequest); + + // 如果是复制新增, 同步MS附件到Jira + if (StringUtils.isNotEmpty(issuesRequest.getCopyIssueId())) { + AttachmentRequest attachmentRequest = new AttachmentRequest(); + attachmentRequest.setBelongId(issuesRequest.getCopyIssueId()); + attachmentRequest.setBelongType(AttachmentType.ISSUE.type()); + List attachmentIds = attachmentService.getAttachmentIdsByParam(attachmentRequest); + if (CollectionUtils.isNotEmpty(attachmentIds)) { + for (String attachmentId : attachmentIds) { + FileAttachmentMetadata fileAttachmentMetadata = attachmentService.getFileAttachmentMetadataByFileId(attachmentId); + File file = new File(fileAttachmentMetadata.getFilePath() + "/" + fileAttachmentMetadata.getName()); + attachmentService.syncIssuesAttachment(issues, file, AttachmentSyncType.UPLOAD); + } + } + } + } else { + List platformList = getAddPlatforms(issuesRequest); + for (IssuesPlatform platform : platformList) { + issues = platform.addIssue(issuesRequest); + } } + if (issuesRequest.getIsPlanEdit()) { issuesRequest.getAddResourceIds().forEach(l -> { testCaseIssueService.updateIssuesCount(l); }); } - saveFollows(issuesRequest.getId(), issuesRequest.getFollows()); - customFieldIssuesService.addFields(issuesRequest.getId(), issuesRequest.getAddFields()); - customFieldIssuesService.editFields(issuesRequest.getId(), issuesRequest.getEditFields()); + String issuesId = issues.getId(); + saveFollows(issuesId, issuesRequest.getFollows()); + customFieldIssuesService.addFields(issuesId, issuesRequest.getAddFields()); + customFieldIssuesService.editFields(issuesId, issuesRequest.getEditFields()); if (StringUtils.isNotEmpty(issuesRequest.getCopyIssueId())) { final String platformId = issues.getPlatformId(); // 复制新增, 同步缺陷的MS附件 @@ -215,11 +261,15 @@ public class IssuesService { fileAttachmentMetadataBatchMapper.insert(fileAttachmentMetadata); // 下载文件管理文件, 同步到第三方平台 File refFile = attachmentService.downloadMetadataFile(filemetaId, fileMetadata.getName()); - IssuesRequest addIssueRequest = new IssuesRequest(); - addIssueRequest.setWorkspaceId(SessionUtils.getCurrentWorkspaceId()); - addIssueRequest.setProjectId(SessionUtils.getCurrentProjectId()); - Objects.requireNonNull(IssueFactory.createPlatform(platform, addIssueRequest)) - .syncIssuesAttachment(issuesRequest, refFile, AttachmentSyncType.UPLOAD); + if (PlatformPluginService.isPluginPlatform(platform)) { + attachmentService.syncIssuesAttachment(issuesRequest, refFile, AttachmentSyncType.UPLOAD); + } else { + IssuesRequest addIssueRequest = new IssuesRequest(); + addIssueRequest.setWorkspaceId(SessionUtils.getCurrentWorkspaceId()); + addIssueRequest.setProjectId(SessionUtils.getCurrentProjectId()); + Objects.requireNonNull(IssueFactory.createPlatform(platform, addIssueRequest)) + .syncIssuesAttachment(issuesRequest, refFile, AttachmentSyncType.UPLOAD); + } FileUtils.deleteFile(FileUtils.ATTACHMENT_TMP_DIR + File.separator + fileMetadata.getName()); }); sqlSession.flushStatements(); @@ -231,11 +281,90 @@ public class IssuesService { return getIssue(issues.getId()); } + protected IssuesWithBLOBs insertIssues(IssuesWithBLOBs issues) { + if (StringUtils.isBlank(issues.getId())) { + issues.setId(UUID.randomUUID().toString()); + } + issues.setCreateTime(System.currentTimeMillis()); + issues.setUpdateTime(System.currentTimeMillis()); + issues.setNum(getNextNum(issues.getProjectId())); + issues.setCreator(SessionUtils.getUserId()); + issuesMapper.insert(issues); + return issues; + } + + protected int getNextNum(String projectId) { + Issues issue = extIssuesMapper.getNextNum(projectId); + if (issue == null || issue.getNum() == null) { + return 100001; + } else { + return Optional.of(issue.getNum() + 1).orElse(100001); + } + } + + protected void handleTestCaseIssues(IssuesUpdateRequest issuesRequest) { + String issuesId = issuesRequest.getId(); + List deleteCaseIds = issuesRequest.getDeleteResourceIds(); + + if (!org.springframework.util.CollectionUtils.isEmpty(deleteCaseIds)) { + TestCaseIssuesExample example = new TestCaseIssuesExample(); + example.createCriteria().andResourceIdIn(deleteCaseIds); + // 测试计划的用例 deleteCaseIds 是空的, 不会进到这里 + example.or(example.createCriteria().andRefIdIn(deleteCaseIds)); + testCaseIssuesMapper.deleteByExample(example); + } + + List addCaseIds = issuesRequest.getAddResourceIds(); + TestCaseIssueService testCaseIssueService = CommonBeanFactory.getBean(TestCaseIssueService.class); + + if (!org.springframework.util.CollectionUtils.isEmpty(addCaseIds)) { + if (issuesRequest.getIsPlanEdit()) { + addCaseIds.forEach(caseId -> { + testCaseIssueService.add(issuesId, caseId, issuesRequest.getRefId(), IssueRefType.PLAN_FUNCTIONAL.name()); + testCaseIssueService.updateIssuesCount(caseId); + }); + } else { + addCaseIds.forEach(caseId -> testCaseIssueService.add(issuesId, caseId, null, IssueRefType.FUNCTIONAL.name())); + } + } + } + public IssuesWithBLOBs updateIssues(IssuesUpdateRequest issuesRequest) { - List platformList = getUpdatePlatforms(issuesRequest); - platformList.forEach(platform -> { - platform.updateIssue(issuesRequest); - }); + PlatformIssuesUpdateRequest platformIssuesUpdateRequest = JSON.parseObject(JSON.toJSONString(issuesRequest), PlatformIssuesUpdateRequest.class); + Project project = baseProjectService.getProjectById(issuesRequest.getProjectId()); + if (PlatformPluginService.isPluginPlatform(project.getPlatform())) { + + Platform platform = platformPluginService.getPlatform(project.getPlatform()); + + if (platform.isAttachmentUploadSupport()) { + AttachmentRequest attachmentRequest = new AttachmentRequest(); + attachmentRequest.setBelongId(issuesRequest.getId()); + attachmentRequest.setBelongType(AttachmentType.ISSUE.type()); + List fileAttachmentMetadata = attachmentService.listMetadata(attachmentRequest); + Set msAttachmentNames = fileAttachmentMetadata.stream() + .map(FileAttachmentMetadata::getName) + .collect(Collectors.toSet()); + // 获得缺陷MS附件名称 + platformIssuesUpdateRequest.setMsAttachmentNames(msAttachmentNames); + } + + List customFieldItemDTOS = JSON.parseArray(JSON.toJSONString(issuesRequest.getRequestFields()), PlatformCustomFieldItemDTO.class); + platformIssuesUpdateRequest.setCustomFieldList(customFieldItemDTOS); // todo 全部插件化后去掉 + platformIssuesUpdateRequest.setUserPlatformUserConfig(userService.getCurrentPlatformInfoStr(SessionUtils.getCurrentWorkspaceId())); + platformIssuesUpdateRequest.setProjectConfig(PlatformPluginService.getCompatibleProjectConfig(project)); + IssuesWithBLOBs issue = platformPluginService.getPlatform(project.getPlatform()) + .updateIssue(platformIssuesUpdateRequest); + + issue.setUpdateTime(System.currentTimeMillis()); + issuesMapper.updateByPrimaryKeySelective(issue); + handleTestCaseIssues(issuesRequest); + } else { + List platformList = getUpdatePlatforms(issuesRequest); + platformList.forEach(platform -> { + platform.updateIssue(issuesRequest); + }); + } + customFieldIssuesService.editFields(issuesRequest.getId(), issuesRequest.getEditFields()); customFieldIssuesService.addFields(issuesRequest.getId(), issuesRequest.getAddFields()); @@ -377,7 +506,7 @@ public class IssuesService { if (jira) { String jiraKey = project.getJiraKey(); - if (StringUtils.isNotBlank(jiraKey) && StringUtils.equals(project.getPlatform(), IssuesManagePlatform.Jira.toString())) { + if (StringUtils.isNotBlank(jiraKey) && PlatformPluginService.isPluginPlatform(project.getPlatform())) { platforms.add(IssuesManagePlatform.Jira.name()); } } @@ -479,8 +608,15 @@ public class IssuesService { Project project = baseProjectService.getProjectById(projectId); IssuesRequest issuesRequest = new IssuesRequest(); issuesRequest.setWorkspaceId(project.getWorkspaceId()); - IssuesPlatform platform = IssueFactory.createPlatform(issuesWithBLOBs.getPlatform(), issuesRequest); - platform.deleteIssue(id); + if (PlatformPluginService.isPluginPlatform(issuesWithBLOBs.getPlatform())) { + platformPluginService.getPlatform(issuesWithBLOBs.getPlatform()) + .deleteIssue(issuesWithBLOBs.getPlatformId()); + deleteIssue(id); + } else { + IssuesPlatform platform = IssueFactory.createPlatform(issuesWithBLOBs.getPlatform(), issuesRequest); + platform.deleteIssue(id); + } + // 删除缺陷对应的附件 AttachmentRequest request = new AttachmentRequest(); request.setBelongId(id); @@ -750,13 +886,6 @@ public class IssuesService { return issueMap; } - public Map getPlatformMap(IssuesRequest request) { - Project project = baseProjectService.getProjectById(request.getProjectId()); - List platforms = getPlatforms(project); - platforms.add(IssuesManagePlatform.Local.toString()); - return IssueFactory.createPlatformsForMap(platforms, request); - } - public void syncThirdPartyIssues() { List projectIds = trackProjectService.getThirdPartProjectIds(); projectIds.forEach(id -> { @@ -834,8 +963,14 @@ public class IssuesService { String defaultCustomFields = getDefaultCustomFields(syncRequest.getProjectId()); issuesRequest.setDefaultCustomFields(defaultCustomFields); } - IssuesPlatform platform = IssueFactory.createPlatform(project.getPlatform(), issuesRequest); - syncThirdPartyIssues(platform::syncIssues, project, issues); + if (PlatformPluginService.isPluginPlatform(project.getPlatform())) { + // 分批处理 + SubListUtil.dealForSubList(issues, 500, (subIssue) -> + syncPluginThirdPartyIssues(subIssue, project)); + } else { + IssuesPlatform platform = IssueFactory.createPlatform(project.getPlatform(), issuesRequest); + syncThirdPartyIssues(platform::syncIssues, project, issues); + } } catch (Exception e) { throw e; } finally { @@ -845,6 +980,118 @@ public class IssuesService { return true; } + public void syncPluginThirdPartyIssues(List issues, Project project) { + List platformIssues = JSON.parseArray(JSON.toJSONString(issues), PlatformIssuesDTO.class); + platformIssues.stream().forEach(item -> { + // 给缺陷添加自定义字段 + List platformCustomFieldList = extIssuesMapper.getIssueCustomField(item.getId()).stream() + .map(field -> { + PlatformCustomFieldItemDTO platformCustomFieldItemDTO = new PlatformCustomFieldItemDTO(); + BeanUtils.copyBean(platformCustomFieldItemDTO, field); + return platformCustomFieldItemDTO; + }) + .collect(Collectors.toList()); + item.setCustomFieldList(platformCustomFieldList); + }); + SyncIssuesRequest request = new SyncIssuesRequest(); + request.setIssues(platformIssues); + request.setProjectConfig(PlatformPluginService.getCompatibleProjectConfig(project)); + Platform platform = platformPluginService.getPlatform(project.getPlatform()); + + // 获取需要变更的缺陷 + SyncIssuesResult syncIssuesResult = platform.syncIssues(request); + List updateIssues = syncIssuesResult.getUpdateIssues(); + + SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH); + IssuesMapper issueBatchMapper = sqlSession.getMapper(IssuesMapper.class); + AttachmentModuleRelationMapper batchAttachmentModuleRelationMapper = sqlSession.getMapper(AttachmentModuleRelationMapper.class); + + // 批量更新 + updateIssues.stream() + .map(item -> { + IssuesWithBLOBs issuesWithBLOBs = new IssuesWithBLOBs(); + BeanUtils.copyBean(issuesWithBLOBs, item); + return issuesWithBLOBs; + }) + .forEach(issueBatchMapper::updateByPrimaryKeySelective); + + // 批量删除 + syncIssuesResult.getDeleteIssuesIds() + .stream() + .forEach(issueBatchMapper::deleteByPrimaryKey); + + try { + // 同步附件 + syncPluginIssueAttachment(platform, syncIssuesResult, batchAttachmentModuleRelationMapper); + } catch (Exception e) { + LogUtil.error(e); + } + + HashMap> customFieldMap = new HashMap<>(); + updateIssues.forEach(item -> { + List customFieldResource = baseCustomFieldService.getCustomFieldResourceDTO(item.getCustomFields()); + customFieldMap.put(item.getId(), customFieldResource); + }); + + // 修改自定义字段 + customFieldIssuesService.batchEditFields(customFieldMap); + } + + private void syncPluginIssueAttachment(Platform platform, SyncIssuesResult syncIssuesResult, AttachmentModuleRelationMapper batchAttachmentModuleRelationMapper) { + Map> attachmentMap = syncIssuesResult.getAttachmentMap(); + if (MapUtils.isNotEmpty(attachmentMap)) { + for (String issueId : attachmentMap.keySet()) { + // 查询我们平台的附件 + Set jiraAttachmentSet = new HashSet<>(); + AttachmentRequest attachmentRequest = new AttachmentRequest(); + attachmentRequest.setBelongType(AttachmentType.ISSUE.type()); + attachmentRequest.setBelongId(issueId); + List allMsAttachments = attachmentService.listMetadata(attachmentRequest); + Set attachmentsNameSet = allMsAttachments.stream() + .map(FileAttachmentMetadata::getName) + .collect(Collectors.toSet()); + + List syncAttachments = attachmentMap.get(issueId); + for (PlatformAttachment syncAttachment : syncAttachments) { + jiraAttachmentSet.add(syncAttachment.getFileName()); + if (!attachmentsNameSet.contains(syncAttachment.getFileName())) { + try { + byte[] content = platform.getAttachmentContent(syncAttachment.getFileKey()); + if (content == null) { + continue; + } + FileAttachmentMetadata fileAttachmentMetadata = attachmentService + .saveAttachmentByBytes(content, AttachmentType.ISSUE.type(), issueId, syncAttachment.getFileName()); + AttachmentModuleRelation attachmentModuleRelation = new AttachmentModuleRelation(); + attachmentModuleRelation.setAttachmentId(fileAttachmentMetadata.getId()); + attachmentModuleRelation.setRelationId(issueId); + attachmentModuleRelation.setRelationType(AttachmentType.ISSUE.type()); + batchAttachmentModuleRelationMapper.insert(attachmentModuleRelation); + } catch (Exception e) { + LogUtil.error(e); + } + } + } + + // 删除Jira中不存在的附件 + if (CollectionUtils.isNotEmpty(allMsAttachments)) { + List deleteMsAttachments = allMsAttachments.stream() + .filter(msAttachment -> !jiraAttachmentSet.contains(msAttachment.getName())) + .collect(Collectors.toList()); + deleteMsAttachments.forEach(fileAttachmentMetadata -> { + List ids = List.of(fileAttachmentMetadata.getId()); + AttachmentModuleRelationExample example = new AttachmentModuleRelationExample(); + example.createCriteria().andAttachmentIdIn(ids).andRelationTypeEqualTo(AttachmentType.ISSUE.type()); + // 删除MS附件及关联数据 + attachmentService.deleteAttachmentByIds(ids); + attachmentService.deleteFileAttachmentByIds(ids); + batchAttachmentModuleRelationMapper.deleteByExample(example); + }); + } + } + } + } + /** * 获取默认的自定义字段的取值,同步之后更新成第三方平台的值 @@ -967,6 +1214,7 @@ public class IssuesService { /** * 获取缺陷状态的自定义字段替换 + * * @param planIssues * @param planId */ @@ -1063,38 +1311,17 @@ public class IssuesService { return issuesMapper.selectByExampleWithBLOBs(example); } - public List getPlatformIssueByIds(List platformIds, String projectId) { - // todo 是否保留 - List issues = extIssuesMapper.getPlatformIssueByIds(platformIds, projectId); - if (CollectionUtils.isEmpty(issues)) { - return issues; - } - List issueIds = issues.stream().map(IssuesDao::getId).collect(Collectors.toList()); - List issuesList = extIssuesMapper.getIssueCustomFields(issueIds); - Map> map = new HashMap<>(); - issuesList.forEach(f -> { - CustomFieldItemDTO dto = new CustomFieldItemDTO(); - dto.setId(f.getFieldId()); - dto.setName(f.getFieldName()); - dto.setType(f.getFieldType()); - dto.setValue(f.getFieldValue()); - dto.setCustomData(f.getCustomData()); - List list = Optional.ofNullable(map.get(f.getId())).orElse(new ArrayList<>()); - map.put(f.getId(), list); - list.add(dto); - }); - issues.forEach(i -> i.setCustomFieldList(map.getOrDefault(i.getId(), new ArrayList<>()))); - return issues; - } - - public IssueTemplateDao getThirdPartTemplate(String projectId) { + IssueTemplateDao issueTemplateDao = new IssueTemplateDao(); if (StringUtils.isNotBlank(projectId)) { Project project = baseProjectService.getProjectById(projectId); - return IssueFactory.createPlatform(IssuesManagePlatform.Jira.toString(), getDefaultIssueRequest(projectId, project.getWorkspaceId())) - .getThirdPartTemplate(); + List thirdPartCustomField = platformPluginService.getPlatform(project.getPlatform(), project.getWorkspaceId()) + .getThirdPartCustomField(PlatformPluginService.getCompatibleProjectConfig(project)); + List customFieldDaoList = JSON.parseArray(JSON.toJSONString(thirdPartCustomField), CustomFieldDao.class); + issueTemplateDao.setCustomFields(customFieldDaoList); + issueTemplateDao.setPlatform(project.getPlatform()); } - return new IssueTemplateDao(); + return issueTemplateDao; } public IssuesRequest getDefaultIssueRequest(String projectId, String workspaceId) { @@ -1104,24 +1331,20 @@ public class IssuesService { return issuesRequest; } - public List getIssueTypes(JiraIssueTypeRequest request) { - IssuesRequest issuesRequest = getDefaultIssueRequest(request.getProjectId(), request.getWorkspaceId()); - JiraPlatform platform = (JiraPlatform) IssueFactory.createPlatform(IssuesManagePlatform.Jira.toString(), issuesRequest); - if (StringUtils.isNotBlank(request.getJiraKey())) { - return platform.getIssueTypes(request.getJiraKey()); - } else { - return new ArrayList<>(); - } - } - - public List getDemandList(String projectId) { + public List getDemandList(String projectId) { Project project = baseProjectService.getProjectById(projectId); String workspaceId = project.getWorkspaceId(); - IssuesRequest issueRequest = new IssuesRequest(); - issueRequest.setWorkspaceId(workspaceId); - issueRequest.setProjectId(projectId); - IssuesPlatform platform = IssueFactory.createPlatform(project.getPlatform(), issueRequest); - return platform.getDemandList(projectId); + + if (PlatformPluginService.isPluginPlatform(project.getPlatform())) { + return platformPluginService.getPlatform(project.getPlatform()) + .getDemands(PlatformPluginService.getCompatibleProjectConfig(project)); + } else { + IssuesRequest issueRequest = new IssuesRequest(); + issueRequest.setWorkspaceId(workspaceId); + issueRequest.setProjectId(projectId); + IssuesPlatform platform = IssueFactory.createPlatform(project.getPlatform(), issueRequest); + return platform.getDemandList(projectId); + } } public List listByWorkspaceId(IssuesRequest request) { @@ -1134,47 +1357,36 @@ public class IssuesService { if (!StringUtils.isBlank(request.getPlatformKey())) { Project project = baseProjectService.getProjectById(request.getProjectId()); - List platforms = getPlatforms(project); - if (CollectionUtils.isEmpty(platforms)) { - return platformStatusDTOS; - } + String platform = project.getPlatform(); + if (PlatformPluginService.isPluginPlatform(platform)) { + return platformPluginService.getPlatform(platform) + .getStatusList(request.getPlatformKey()) + .stream().map(item -> { + PlatformStatusDTO platformStatusDTO = new PlatformStatusDTO(); + platformStatusDTO.setLabel(item.getLabel()); + platformStatusDTO.setValue(item.getValue()); + return platformStatusDTO; + }) + .collect(Collectors.toList()); + } else { + List platforms = getPlatforms(project); + if (CollectionUtils.isEmpty(platforms)) { + return platformStatusDTOS; + } - IssuesRequest issuesRequest = getDefaultIssueRequest(request.getProjectId(), request.getWorkspaceId()); - Map platformMap = IssueFactory.createPlatformsForMap(platforms, issuesRequest); - try { - if (platformMap.size() > 1) { - MSException.throwException(Translator.get("project_reference_multiple_plateform")); - } - Optional platformOptional = platformMap.values().stream().findFirst(); - if (platformOptional.isPresent()) { - platformStatusDTOS = platformOptional.get().getTransitions(request.getPlatformKey()); - } - } catch (Exception e) { - LogUtil.error(e); + IssuesRequest issuesRequest = getDefaultIssueRequest(request.getProjectId(), request.getWorkspaceId()); + return IssueFactory.createPlatform(platform, issuesRequest).getTransitions(request.getPlatformKey()); } } - return platformStatusDTOS; } - public void deleteIssueAttachments(String issueId) { - attachmentService.deleteAttachment(AttachmentType.ISSUE.type(), issueId); - IssueFileExample example = new IssueFileExample(); - example.createCriteria().andIssueIdEqualTo(issueId); - List issueFiles = issueFileMapper.selectByExample(example); - if (issueFiles.size() == 0) { - return; - } - List ids = issueFiles.stream().map(IssueFile::getFileId).collect(Collectors.toList()); - attachmentService.deleteFileAttachmentByIds(ids); - issueFileMapper.deleteByExample(example); - } - public boolean isThirdPartTemplate(Project project) { - return project.getThirdPartTemplate() != null && project.getThirdPartTemplate() && project.getPlatform().equals(IssuesManagePlatform.Jira.name()); + return project.getThirdPartTemplate() != null + && project.getThirdPartTemplate() + && PlatformPluginService.isPluginPlatform(project.getPlatform()); } - public void checkThirdProjectExist(Project project) { IssuesRequest issuesRequest = new IssuesRequest(); if (StringUtils.isBlank(project.getId())) { @@ -1373,9 +1585,10 @@ public class IssuesService { } private IssueTemplateDao getIssueTemplateByProjectId(String projectId) { - IssueTemplateDao issueTemplateDao = new IssueTemplateDao(); + IssueTemplateDao issueTemplateDao; Project project = baseProjectService.getProjectById(projectId); - if (StringUtils.equals(project.getPlatform(), IssuesManagePlatform.Jira.name()) && project.getThirdPartTemplate()) { + if (PlatformPluginService.isPluginPlatform(project.getPlatform()) + && project.getThirdPartTemplate()) { // 第三方Jira平台 issueTemplateDao = getThirdPartTemplate(project.getId()); issueTemplateDao.setIsThirdTemplate(Boolean.TRUE); @@ -1407,7 +1620,7 @@ public class IssuesService { return filterIssues; } - private void uploadAzureCopyAttachment(AttachmentRequest attachmentRequest, String platform, String platformId) { + private void uploadAzureCopyAttachment(AttachmentRequest attachmentRequest, String platform, String platformId) { List attachmentIds = attachmentService.getAttachmentIdsByParam(attachmentRequest); if (CollectionUtils.isNotEmpty(attachmentIds)) { attachmentIds.forEach(attachmentId -> { @@ -1478,4 +1691,10 @@ public class IssuesService { } } } + + public boolean thirdPartTemplateEnable(String projectId) { + Project project = baseProjectService.getProjectById(projectId); + return BooleanUtils.isTrue(project.getThirdPartTemplate()) + && platformPluginService.isThirdPartTemplateSupport(project.getPlatform()); + } } diff --git a/test-track/backend/src/main/java/io/metersphere/service/PlatformPluginService.java b/test-track/backend/src/main/java/io/metersphere/service/PlatformPluginService.java index daa4c3a4ed..87ce5c9043 100644 --- a/test-track/backend/src/main/java/io/metersphere/service/PlatformPluginService.java +++ b/test-track/backend/src/main/java/io/metersphere/service/PlatformPluginService.java @@ -1,15 +1,26 @@ package io.metersphere.service; +import io.metersphere.commons.constants.IssuesManagePlatform; +import io.metersphere.commons.utils.JSON; +import io.metersphere.platform.api.Platform; +import io.metersphere.platform.api.PluginMetaInfo; import io.metersphere.base.domain.PluginWithBLOBs; +import io.metersphere.base.domain.Project; +import io.metersphere.base.domain.ServiceIntegration; import io.metersphere.commons.constants.PluginScenario; -import io.metersphere.loader.PlatformPluginManager; +import io.metersphere.commons.utils.SessionUtils; +import io.metersphere.platform.domain.PlatformRequest; +import io.metersphere.platform.loader.PlatformPluginManager; +import io.metersphere.request.IntegrationRequest; import io.metersphere.utils.PluginManagerUtil; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.io.InputStream; import java.util.List; +import java.util.Map; @Service @Transactional(rollbackFor = Exception.class) @@ -19,6 +30,8 @@ public class PlatformPluginService { private BasePluginService basePluginService; @Resource private BaseIntegrationService baseIntegrationService; + @Resource + private BaseProjectService baseProjectService; private PlatformPluginManager pluginManager; @@ -46,4 +59,48 @@ public class PlatformPluginService { public void unloadPlugin(String pluginId) { pluginManager.deletePlugin(pluginId); } + + public boolean isThirdPartTemplateSupport(String platform) { + if (StringUtils.isBlank(platform)) { + return false; + } + PluginMetaInfo pluginMetaInfo = pluginManager.getPluginMetaInfoByKey(platform); + return pluginMetaInfo.isThirdPartTemplateSupport(); + } + + public Platform getPlatform(String platformKey, String workspaceId) { + IntegrationRequest integrationRequest = new IntegrationRequest(); + integrationRequest.setPlatform(platformKey); + integrationRequest.setWorkspaceId(StringUtils.isBlank(workspaceId) ? SessionUtils.getCurrentWorkspaceId() : workspaceId); + ServiceIntegration serviceIntegration = baseIntegrationService.get(integrationRequest); + + PlatformRequest pluginRequest = new PlatformRequest(); + pluginRequest.setIntegrationConfig(serviceIntegration.getConfiguration()); + return pluginManager.getPlatformByKey(platformKey, pluginRequest); + } + + public Platform getPlatform(String platformKey) { + return this.getPlatform(platformKey, null); + } + + + public static String getCompatibleProjectConfig(Project project) { + String issueConfig = project.getIssueConfig(); + Map map = JSON.parseMap(issueConfig); + map.put("jiraKey", project.getJiraKey()); + map.put("tapdId", project.getTapdId()); + map.put("azureDevopsId", project.getAzureDevopsId()); + map.put("zentaoId", project.getZentaoId()); + map.put("thirdPartTemplate", project.getThirdPartTemplate()); + return JSON.toJSONString(map); + } + + public static boolean isPluginPlatform(String platform) { + if (StringUtils.equalsAnyIgnoreCase(platform, + IssuesManagePlatform.Tapd.name(), IssuesManagePlatform.AzureDevops.name(), + IssuesManagePlatform.Zentao.name(), IssuesManagePlatform.Local.name())) { + return false; + } + return true; + } } diff --git a/test-track/backend/src/main/java/io/metersphere/service/issue/platform/AbstractIssuePlatform.java b/test-track/backend/src/main/java/io/metersphere/service/issue/platform/AbstractIssuePlatform.java index 817a995a51..2bec9b95d0 100644 --- a/test-track/backend/src/main/java/io/metersphere/service/issue/platform/AbstractIssuePlatform.java +++ b/test-track/backend/src/main/java/io/metersphere/service/issue/platform/AbstractIssuePlatform.java @@ -11,19 +11,16 @@ import io.metersphere.commons.constants.IssuesStatus; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.*; import io.metersphere.dto.CustomFieldItemDTO; -import io.metersphere.xpack.track.dto.IssueSyncRequest; -import io.metersphere.xpack.track.dto.IssueTemplateDao; -import io.metersphere.xpack.track.dto.PlatformStatusDTO; import io.metersphere.dto.UserDTO; import io.metersphere.request.IntegrationRequest; -import io.metersphere.xpack.track.dto.EditTestCaseRequest; -import io.metersphere.xpack.track.dto.request.IssuesRequest; -import io.metersphere.xpack.track.dto.request.IssuesUpdateRequest; import io.metersphere.service.*; -import io.metersphere.xpack.track.issue.IssuesPlatform; import io.metersphere.service.issue.domain.ProjectIssueConfig; import io.metersphere.service.wapper.TrackProjectService; import io.metersphere.service.wapper.UserService; +import io.metersphere.xpack.track.dto.*; +import io.metersphere.xpack.track.dto.request.IssuesRequest; +import io.metersphere.xpack.track.dto.request.IssuesUpdateRequest; +import io.metersphere.xpack.track.issue.IssuesPlatform; import org.apache.commons.lang3.StringUtils; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; @@ -654,4 +651,8 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform { return null; } + @Override + public List getIssue(IssuesRequest request) { + return null; + } } diff --git a/test-track/backend/src/main/java/io/metersphere/service/issue/platform/IssueFactory.java b/test-track/backend/src/main/java/io/metersphere/service/issue/platform/IssueFactory.java index f8517e7389..23cda366a3 100644 --- a/test-track/backend/src/main/java/io/metersphere/service/issue/platform/IssueFactory.java +++ b/test-track/backend/src/main/java/io/metersphere/service/issue/platform/IssueFactory.java @@ -16,8 +16,6 @@ public class IssueFactory { public static IssuesPlatform createPlatform(String platform, IssuesRequest addIssueRequest) { if (StringUtils.equals(IssuesManagePlatform.Tapd.toString(), platform)) { return new TapdPlatform(addIssueRequest); - } else if (StringUtils.equals(IssuesManagePlatform.Jira.toString(), platform)) { - return new JiraPlatform(addIssueRequest); } else if (StringUtils.equals(IssuesManagePlatform.Zentao.toString(), platform)) { return new ZentaoPlatform(addIssueRequest); } else if (StringUtils.equals(IssuesManagePlatform.AzureDevops.toString(), platform)) { @@ -46,15 +44,4 @@ public class IssueFactory { }); return platforms; } - - public static Map createPlatformsForMap(List types, IssuesRequest addIssueRequest) { - Map platformMap = new HashMap<>(); - types.forEach(type -> { - IssuesPlatform abstractIssuePlatform = createPlatform(type, addIssueRequest); - if (abstractIssuePlatform != null) { - platformMap.put(type, abstractIssuePlatform); - } - }); - return platformMap; - } } diff --git a/test-track/backend/src/main/java/io/metersphere/service/issue/platform/LocalPlatform.java b/test-track/backend/src/main/java/io/metersphere/service/issue/platform/LocalPlatform.java index b28603f343..fc92a9c15d 100644 --- a/test-track/backend/src/main/java/io/metersphere/service/issue/platform/LocalPlatform.java +++ b/test-track/backend/src/main/java/io/metersphere/service/issue/platform/LocalPlatform.java @@ -2,19 +2,17 @@ package io.metersphere.service.issue.platform; import io.metersphere.base.domain.IssuesWithBLOBs; - import io.metersphere.commons.constants.IssuesManagePlatform; import io.metersphere.commons.user.SessionUser; import io.metersphere.commons.utils.BeanUtils; import io.metersphere.commons.utils.JSON; import io.metersphere.commons.utils.SessionUtils; -import io.metersphere.xpack.track.dto.AttachmentSyncType; import io.metersphere.dto.CustomFieldItemDTO; +import io.metersphere.request.testcase.TestCaseBatchRequest; +import io.metersphere.xpack.track.dto.AttachmentSyncType; import io.metersphere.xpack.track.dto.DemandDTO; -import io.metersphere.xpack.track.dto.IssuesDao; import io.metersphere.xpack.track.dto.request.IssuesRequest; import io.metersphere.xpack.track.dto.request.IssuesUpdateRequest; -import io.metersphere.request.testcase.TestCaseBatchRequest; import org.apache.commons.lang3.StringUtils; import java.io.File; @@ -29,16 +27,6 @@ public class LocalPlatform extends LocalAbstractPlatform { super(issuesRequest); } - @Override - public List getIssue(IssuesRequest issuesRequest) { - String projectId = issuesRequest.getProjectId(); - issuesRequest.setPlatform(IssuesManagePlatform.Local.toString()); - if (StringUtils.isNotBlank(projectId)) { - return extIssuesMapper.getIssues(issuesRequest); - } - return extIssuesMapper.getIssuesByCaseId(issuesRequest); - } - @Override public List getDemandList(String projectId) { return null; diff --git a/test-track/backend/src/main/java/io/metersphere/service/plugin/MinioStorageStrategy.java b/test-track/backend/src/main/java/io/metersphere/service/plugin/MinioStorageStrategy.java index 41e0d9a8aa..a18977353e 100644 --- a/test-track/backend/src/main/java/io/metersphere/service/plugin/MinioStorageStrategy.java +++ b/test-track/backend/src/main/java/io/metersphere/service/plugin/MinioStorageStrategy.java @@ -1,6 +1,6 @@ package io.metersphere.service.plugin; -import im.metersphere.storage.StorageStrategy; +import im.metersphere.plugin.storage.StorageStrategy; import io.metersphere.commons.constants.StorageConstants; import io.metersphere.commons.utils.CommonBeanFactory; import io.metersphere.metadata.service.FileManagerService; diff --git a/test-track/backend/src/main/java/io/metersphere/service/wapper/IssueProxyResourceService.java b/test-track/backend/src/main/java/io/metersphere/service/wapper/IssueProxyResourceService.java index 884e4c548f..6590022e1c 100644 --- a/test-track/backend/src/main/java/io/metersphere/service/wapper/IssueProxyResourceService.java +++ b/test-track/backend/src/main/java/io/metersphere/service/wapper/IssueProxyResourceService.java @@ -1,10 +1,9 @@ package io.metersphere.service.wapper; import io.metersphere.commons.exception.MSException; -import io.metersphere.commons.utils.SessionUtils; import io.metersphere.i18n.Translator; +import io.metersphere.service.PlatformPluginService; import io.metersphere.xpack.track.dto.request.IssuesRequest; -import io.metersphere.service.issue.platform.IssueFactory; import org.apache.commons.lang3.StringUtils; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; @@ -20,6 +19,8 @@ public class IssueProxyResourceService { @Resource private RestTemplate restTemplate; + @Resource + private PlatformPluginService platformPluginService; /** * http 代理 @@ -37,8 +38,9 @@ public class IssueProxyResourceService { IssuesRequest issuesRequest = new IssuesRequest(); issuesRequest.setProjectId(projectId); issuesRequest.setWorkspaceId(workspaceId); - return IssueFactory.createPlatform(platform, issuesRequest) + return platformPluginService.getPlatform(platform) .proxyForGet(url, byte[].class); + } return restTemplate.exchange(url, HttpMethod.GET, null, byte[].class); } diff --git a/test-track/backend/src/main/java/io/metersphere/service/wapper/UserService.java b/test-track/backend/src/main/java/io/metersphere/service/wapper/UserService.java index d169d80295..971a412814 100644 --- a/test-track/backend/src/main/java/io/metersphere/service/wapper/UserService.java +++ b/test-track/backend/src/main/java/io/metersphere/service/wapper/UserService.java @@ -34,4 +34,9 @@ public class UserService { } return JSON.parseObject(JSON.toJSONString(platformInfo), UserDTO.PlatformInfo.class); } + + public String getCurrentPlatformInfoStr(String workspaceId) { + UserDTO.PlatformInfo currentPlatformInfo = getCurrentPlatformInfo(workspaceId); + return currentPlatformInfo == null ? null : JSON.toJSONString(currentPlatformInfo); + } } diff --git a/test-track/backend/src/main/java/io/metersphere/utils/PluginManagerUtil.java b/test-track/backend/src/main/java/io/metersphere/utils/PluginManagerUtil.java index dc7143398a..729ff7971e 100644 --- a/test-track/backend/src/main/java/io/metersphere/utils/PluginManagerUtil.java +++ b/test-track/backend/src/main/java/io/metersphere/utils/PluginManagerUtil.java @@ -1,6 +1,6 @@ package io.metersphere.utils; -import im.metersphere.loader.PluginManager; +import im.metersphere.plugin.loader.PluginManager; import io.metersphere.base.domain.PluginWithBLOBs; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.LogUtil; diff --git a/test-track/frontend/src/api/issue.js b/test-track/frontend/src/api/issue.js index 5d4a38d061..a636bc79ab 100644 --- a/test-track/frontend/src/api/issue.js +++ b/test-track/frontend/src/api/issue.js @@ -4,7 +4,7 @@ import {getUUID} from "metersphere-frontend/src/utils"; import {getCurrentProjectID, getCurrentWorkspaceId} from "metersphere-frontend/src/utils/token"; import {hasLicense} from "metersphere-frontend/src/utils/permission"; import {getCurrentProject} from "./project"; -import {JIRA, LOCAL} from "metersphere-frontend/src/utils/constants"; +import {LOCAL} from "metersphere-frontend/src/utils/constants"; import {getIssueTemplate} from "./custom-field-template"; import {$success, $warning} from "metersphere-frontend/src/plugins/message"; import i18n from "../i18n"; @@ -212,8 +212,8 @@ export function getPlatformTransitions(param) { return post('/issues/platform/transitions', param); } -export function enableThirdPartTemplate(currentProject) { - return currentProject && currentProject.thirdPartTemplate && currentProject.platform === JIRA; +export function enableThirdPartTemplate(projectId) { + return get(BASE_URL + '/third/part/template/enable/' + projectId); } export function buildIssues(page) { @@ -230,18 +230,21 @@ export function buildIssues(page) { export function getIssuePartTemplateWithProject(callback) { getCurrentProject().then((response) => { let currentProject = response.data; - if (enableThirdPartTemplate(currentProject)) { - getIssueThirdPartTemplate() - .then((template) => { - if (callback) - callback(template, currentProject); - }); - } else { - getIssueTemplate() - .then((template) => { - if (callback) - callback(template, currentProject); - }); - } + enableThirdPartTemplate(currentProject.id) + .then((r) => { + if (r.data) { + getIssueThirdPartTemplate() + .then((template) => { + if (callback) + callback(template, currentProject); + }); + } else { + getIssueTemplate() + .then((template) => { + if (callback) + callback(template, currentProject); + }); + } + }); }); } diff --git a/test-track/frontend/src/business/issue/IssueEditDetail.vue b/test-track/frontend/src/business/issue/IssueEditDetail.vue index d86002f6f9..281e9ba6cc 100644 --- a/test-track/frontend/src/business/issue/IssueEditDetail.vue +++ b/test-track/frontend/src/business/issue/IssueEditDetail.vue @@ -6,25 +6,33 @@ - + - - - + + + - - + +
- - + + - - + +
@@ -118,10 +126,14 @@ :on-success="handleSuccess" :on-error="handleError" :disabled="readOnly || type === 'copy'"> - {{$t('permission.project_file.local_upload')}} + + {{ $t('permission.project_file.local_upload') }} + - {{ $t('permission.project_file.associated_files') }} + + {{ $t('permission.project_file.associated_files') }} + @@ -198,7 +210,12 @@ import CustomFiledComponent from "metersphere-frontend/src/components/template/C import TestCaseIssueList from "@/business/issue/TestCaseIssueList"; import IssueEditDetail from "@/business/issue/IssueEditDetail"; import {byteToSize, getTypeByFileName, getUUID} from "metersphere-frontend/src/utils"; -import {getCurrentProjectID, getCurrentUser, getCurrentWorkspaceId, getCurrentUserId} from "metersphere-frontend/src/utils/token" +import { + getCurrentProjectID, + getCurrentUser, + getCurrentWorkspaceId, + getCurrentUserId +} from "metersphere-frontend/src/utils/token" import {hasLicense} from "metersphere-frontend/src/utils/permission"; import { enableThirdPartTemplate, @@ -250,7 +267,7 @@ export default { data() { return { type: null, - issueId:'', + issueId: '', result: { loading: false }, @@ -275,8 +292,8 @@ export default { description: '', creator: null, remark: null, - tapdUsers:[], - zentaoBuilds:[], + tapdUsers: [], + zentaoBuilds: [], zentaoAssigned: '', platformStatus: null, copyIssueId: '' @@ -335,6 +352,7 @@ export default { relateFiles: [], unRelateFiles: [], dumpFile: {}, + enableThirdPartTemplate: false }; }, props: { @@ -356,9 +374,6 @@ export default { projectId() { return getCurrentProjectID(); }, - enableThirdPartTemplate() { - return enableThirdPartTemplate(this.currentProject); - }, }, watch: { tabActiveName() { @@ -376,8 +391,8 @@ export default { description: '', creator: null, remark: null, - tapdUsers:[], - zentaoBuilds:[], + tapdUsers: [], + zentaoBuilds: [], zentaoAssigned: '', platformStatus: null }; @@ -403,6 +418,11 @@ export default { this.currentProject = project; this.init(template, data); this.getDataInfoAsync(data); + + enableThirdPartTemplate(this.currentProject.id) + .then(r => { + this.enableThirdPartTemplate = r.data; + }); }); }); }, @@ -460,21 +480,21 @@ export default { if (platform === 'Zentao') { this.hasZentaoId = true; getZentaoBuilds(data) - .then((response) => { - if (response.data) { - this.Builds = response.data; - } - getZentaoUser(data) .then((response) => { - this.zentaoUsers = response.data; + if (response.data) { + this.Builds = response.data; + } + getZentaoUser(data) + .then((response) => { + this.zentaoUsers = response.data; + }) }) - }) } else if (platform === 'Tapd') { this.hasTapdId = true; getTapdUser(data) - .then((response) => { - this.tapdUsers = response.data; - }) + .then((response) => { + this.tapdUsers = response.data; + }) } }, initEdit(data) { @@ -627,30 +647,30 @@ export default { } }; }, - saveFollow(){ - if(!this.form.follows){ + saveFollow() { + if (!this.form.follows) { this.form.follows = []; } - if(this.showFollow){ + if (this.showFollow) { this.showFollow = false; for (let i = 0; i < this.form.follows.length; i++) { - if(this.form.follows[i]===this.currentUser().id){ - this.form.follows.splice(i,1) + if (this.form.follows[i] === this.currentUser().id) { + this.form.follows.splice(i, 1) break; } } - if(this.url === "issues/update"){ + if (this.url === "issues/update") { saveFollow(this.issueId, this.form.follows).then(() => { this.$success(this.$t('commons.cancel_follow_success')); }) } - }else { + } else { this.showFollow = true; - if(!this.form.follows){ + if (!this.form.follows) { this.form.follows = []; } this.form.follows.push(this.currentUser().id) - if(this.url === "issues/update"){ + if (this.url === "issues/update") { saveFollow(this.issueId, this.form.follows).then(() => { this.$success(this.$t('commons.follow_success')); }) @@ -679,8 +699,8 @@ export default { name: file.name, size: byteToSize(file.size), updateTime: new Date().getTime(), - progress: this.type === 'add' || this.isCaseEdit? 100 : 0, - status: this.type === 'add' || this.isCaseEdit? 'toUpload' : 0, + progress: this.type === 'add' || this.isCaseEdit ? 100 : 0, + status: this.type === 'add' || this.isCaseEdit ? 'toUpload' : 0, creator: user.name, type: getTypeByFileName(file.name), isLocal: true @@ -702,27 +722,27 @@ export default { let CancelToken = axios.CancelToken let self = this; uploadIssueAttachment(file, data, CancelToken, self.cancelFileToken, progressCallback) - .then(response => { // 成功回调 - progress = 100; - param.onSuccess(response); - progressCallback({progress, status: 'success'}); - self.cancelFileToken.forEach((token, index, array)=>{ - if(token.name == file.name){ - array.splice(token,1) - } - }) - }).catch(({error}) => { // 失败回调 + .then(response => { // 成功回调 + progress = 100; + param.onSuccess(response); + progressCallback({progress, status: 'success'}); + self.cancelFileToken.forEach((token, index, array) => { + if (token.name == file.name) { + array.splice(token, 1) + } + }) + }).catch(({error}) => { // 失败回调 progress = 100; progressCallback({progress, status: 'error'}); - self.cancelFileToken.forEach((token, index, array)=>{ - if(token.name == file.name){ - array.splice(token,1) + self.cancelFileToken.forEach((token, index, array) => { + if (token.name == file.name) { + array.splice(token, 1) } }) }); }, showProgress(file, params) { - const { progress, status } = params + const {progress, status} = params const arr = [...this.tableData].map(item => { if (item.name === file.name) { item.progress = progress @@ -737,18 +757,18 @@ export default { }, handleSuccess(response, file, fileList) { let readyFiles = fileList.filter(item => item.status === 'success') - if (readyFiles.length === fileList.length ) { + if (readyFiles.length === fileList.length) { this.getFileMetaData(this.issueId); } }, handleError(err, file, fileList) { let readyFiles = fileList.filter(item => item.status === 'success') - if (readyFiles.length === fileList.length ) { + if (readyFiles.length === fileList.length) { this.getFileMetaData(this.issueId); } }, handleDelete(file, index) { - this.$alert((this.cancelFileToken.length > 0 ? this.$t('load_test.delete_file_when_uploading') + '
': "") + this.$t('load_test.delete_file_confirm') + file.name + "?", '', { + this.$alert((this.cancelFileToken.length > 0 ? this.$t('load_test.delete_file_when_uploading') + '
' : "") + this.$t('load_test.delete_file_confirm') + file.name + "?", '', { confirmButtonText: this.$t('commons.confirm'), dangerouslyUseHTMLString: true, callback: (action) => { @@ -772,10 +792,10 @@ export default { this.uploadFiles.splice(delIndex, 1); } else { deleteIssueAttachment(file.id) - .then(() => { - this.$success(this.$t('commons.delete_success')); - this.getFileMetaData(this.issueId); - }); + .then(() => { + this.$success(this.$t('commons.delete_success')); + this.getFileMetaData(this.issueId); + }); } }, handleUnRelate(file, index) { @@ -797,11 +817,11 @@ export default { let data = {'belongType': 'issue', 'belongId': this.issueId, 'metadataRefIds': this.unRelateFiles}; this.result.loading = true; unrelatedAttachment(data) - .then(() => { - this.$success(this.$t('commons.unrelated_success')); - this.result.loading = false; - this.getFileMetaData(this.issueId); - }) + .then(() => { + this.$success(this.$t('commons.unrelated_success')); + this.result.loading = false; + this.getFileMetaData(this.issueId); + }) } } } @@ -827,7 +847,7 @@ export default { for (let row of rows) { let rowIndex = this.tableData.findIndex(item => item.name === row.name); if (rowIndex >= 0) { - this.$error(this.$t('load_test.exist_related_file') + ": " + row.name); + this.$error(this.$t('load_test.exist_related_file') + ": " + row.name); repeatRecord = true; break; } @@ -856,21 +876,23 @@ export default { let data = {'belongType': 'issue', 'belongId': this.issueId, 'metadataRefIds': metadataRefIds}; this.result.loading = true; relatedAttachment(data) - .then(() => { - this.$success(this.$t('commons.relate_success')); - this.result.loading = false; - this.getFileMetaData(this.issueId); - }); + .then(() => { + this.$success(this.$t('commons.relate_success')); + this.result.loading = false; + this.getFileMetaData(this.issueId); + }); } } }, setModuleId(moduleId) { - let data = {id: getUUID(), resourceId: getCurrentProjectID(), moduleId: moduleId, - projectId: getCurrentProjectID(), fileName: this.dumpFile.name, attachmentId: this.dumpFile.id}; + let data = { + id: getUUID(), resourceId: getCurrentProjectID(), moduleId: moduleId, + projectId: getCurrentProjectID(), fileName: this.dumpFile.name, attachmentId: this.dumpFile.id + }; dumpAttachment(data) - .then(() => { - this.$success(this.$t("organization.integration.successful_operation")); - }); + .then(() => { + this.$success(this.$t("organization.integration.successful_operation")); + }); }, getFileMetaData(id) { if (this.type === 'edit') { @@ -926,7 +948,7 @@ export default { margin-left: 20px; } -.top-input-class{ +.top-input-class { width: 100%; }