From 7ffb6812cffd0561482be04e01efcd9134b42a17 Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Tue, 18 Aug 2020 15:44:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8F=96=E6=B6=88=E9=9B=86=E6=88=90?= =?UTF-8?q?=E5=90=8E,=E8=A7=A3=E9=99=A4=E9=A1=B9=E7=9B=AE=E5=85=B3?= =?UTF-8?q?=E8=81=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/mapper/ext/ExtProjectMapper.java | 2 ++ .../base/mapper/ext/ExtProjectMapper.xml | 24 ++++++++++++++++--- .../service/IntegrationService.java | 5 ++++ .../controller/TestCaseIssuesController.java | 2 +- .../{ => track}/service/IssuesService.java | 19 ++++++--------- ...ectManagement.vue => IssuesManagement.vue} | 18 +++++++------- .../organization/ServiceIntegration.vue | 2 +- 7 files changed, 46 insertions(+), 26 deletions(-) rename backend/src/main/java/io/metersphere/{ => track}/service/IssuesService.java (96%) rename frontend/src/business/components/settings/organization/{DefectManagement.vue => IssuesManagement.vue} (90%) diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.java index b022159557..baafe6c422 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.java @@ -11,4 +11,6 @@ public interface ExtProjectMapper { List getProjectWithWorkspace(@Param("proRequest") ProjectRequest request); List getProjectIdByWorkspaceId(String workspaceId); + + int removeIssuePlatform(@Param("platform") String platform, @Param("orgId") String orgId); } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.xml index 85589a901f..c4c9f8b821 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.xml @@ -4,9 +4,9 @@ + + update project + + + jira_key = null + + + tapd_id = null + + + where project.id in (select id from (select id + from project + where workspace_id in + (select workspace.id + from workspace + where organization_id = #{orgId})) as a) + + \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/service/IntegrationService.java b/backend/src/main/java/io/metersphere/service/IntegrationService.java index 0eb7d56df6..a3522cba37 100644 --- a/backend/src/main/java/io/metersphere/service/IntegrationService.java +++ b/backend/src/main/java/io/metersphere/service/IntegrationService.java @@ -3,6 +3,7 @@ package io.metersphere.service; import io.metersphere.base.domain.ServiceIntegration; import io.metersphere.base.domain.ServiceIntegrationExample; import io.metersphere.base.mapper.ServiceIntegrationMapper; +import io.metersphere.base.mapper.ext.ExtProjectMapper; import io.metersphere.controller.request.IntegrationRequest; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; @@ -20,6 +21,8 @@ public class IntegrationService { @Resource private ServiceIntegrationMapper serviceIntegrationMapper; + @Resource + private ExtProjectMapper extProjectMapper; public ServiceIntegration save(ServiceIntegration service) { ServiceIntegrationExample example = new ServiceIntegrationExample(); @@ -63,6 +66,8 @@ public class IntegrationService { .andOrganizationIdEqualTo(orgId) .andPlatformEqualTo(platform); serviceIntegrationMapper.deleteByExample(example); + // 删除项目关联的id/key + extProjectMapper.removeIssuePlatform(platform, orgId); } public List getAll(String orgId) { diff --git a/backend/src/main/java/io/metersphere/track/controller/TestCaseIssuesController.java b/backend/src/main/java/io/metersphere/track/controller/TestCaseIssuesController.java index 63a88fa974..79a51257f5 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestCaseIssuesController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestCaseIssuesController.java @@ -1,7 +1,7 @@ package io.metersphere.track.controller; import io.metersphere.base.domain.Issues; -import io.metersphere.service.IssuesService; +import io.metersphere.track.service.IssuesService; import io.metersphere.track.request.testcase.IssuesRequest; import org.springframework.web.bind.annotation.*; diff --git a/backend/src/main/java/io/metersphere/service/IssuesService.java b/backend/src/main/java/io/metersphere/track/service/IssuesService.java similarity index 96% rename from backend/src/main/java/io/metersphere/service/IssuesService.java rename to backend/src/main/java/io/metersphere/track/service/IssuesService.java index f38744103b..9afc632d83 100644 --- a/backend/src/main/java/io/metersphere/service/IssuesService.java +++ b/backend/src/main/java/io/metersphere/track/service/IssuesService.java @@ -1,4 +1,4 @@ -package io.metersphere.service; +package io.metersphere.track.service; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; @@ -15,8 +15,9 @@ import io.metersphere.commons.utils.RestTemplateUtils; import io.metersphere.commons.utils.SessionUtils; import io.metersphere.controller.ResultHolder; import io.metersphere.controller.request.IntegrationRequest; +import io.metersphere.service.IntegrationService; +import io.metersphere.service.ProjectService; import io.metersphere.track.request.testcase.IssuesRequest; -import io.metersphere.track.service.TestCaseService; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; @@ -154,12 +155,6 @@ public class IssuesService { String tapdId = getTapdProjectId(issuesRequest.getTestCaseId()); String jiraKey = getJiraProjectKey(issuesRequest.getTestCaseId()); - if (tapd || jira) { - if (StringUtils.isBlank(tapdId) && StringUtils.isBlank(jiraKey)) { - MSException.throwException("集成了缺陷管理平台,但未进行项目关联!"); - } - } - if (tapd) { // 是否关联了项目 if (StringUtils.isNotBlank(tapdId)) { @@ -173,7 +168,7 @@ public class IssuesService { } } - if (!tapd && !jira) { + if (StringUtils.isBlank(tapdId) && StringUtils.isBlank(jiraKey)) { addLocalIssues(issuesRequest); } @@ -322,7 +317,7 @@ public class IssuesService { HttpEntity requestEntity = new HttpEntity<>(headers); RestTemplate restTemplate = new RestTemplate(); //post - ResponseEntity responseEntity = null; + ResponseEntity responseEntity; Issues issues = new Issues(); try { responseEntity = restTemplate.exchange(url + "/rest/api/2/issue/" + issuesId, HttpMethod.GET, requestEntity, String.class); @@ -395,7 +390,7 @@ public class IssuesService { List issues = extIssuesMapper.getIssues(caseId, IssuesManagePlatform.Tapd.toString()); - List issuesIds = issues.stream().map(issue -> issue.getId()).collect(Collectors.toList()); + List issuesIds = issues.stream().map(Issues::getId).collect(Collectors.toList()); issuesIds.forEach(issuesId -> { Issues dto = getTapdIssues(tapdId, issuesId); if (StringUtils.isBlank(dto.getId())) { @@ -437,7 +432,7 @@ public class IssuesService { List issues = extIssuesMapper.getIssues(caseId, IssuesManagePlatform.Jira.toString()); - List issuesIds = issues.stream().map(issue -> issue.getId()).collect(Collectors.toList()); + List issuesIds = issues.stream().map(Issues::getId).collect(Collectors.toList()); issuesIds.forEach(issuesId -> { Issues dto = getJiraIssues(headers, url, issuesId); if (StringUtils.isBlank(dto.getId())) { diff --git a/frontend/src/business/components/settings/organization/DefectManagement.vue b/frontend/src/business/components/settings/organization/IssuesManagement.vue similarity index 90% rename from frontend/src/business/components/settings/organization/DefectManagement.vue rename to frontend/src/business/components/settings/organization/IssuesManagement.vue index 8b5b25ebac..7192c130d8 100644 --- a/frontend/src/business/components/settings/organization/DefectManagement.vue +++ b/frontend/src/business/components/settings/organization/IssuesManagement.vue @@ -1,6 +1,6 @@