提交 7ffb6812 编写于 作者: S shiziyuan9527

fix: 取消集成后,解除项目关联

上级 ab07bc3d
......@@ -11,4 +11,6 @@ public interface ExtProjectMapper {
List<ProjectDTO> getProjectWithWorkspace(@Param("proRequest") ProjectRequest request);
List<String> getProjectIdByWorkspaceId(String workspaceId);
int removeIssuePlatform(@Param("platform") String platform, @Param("orgId") String orgId);
}
......@@ -4,9 +4,9 @@
<select id="getProjectWithWorkspace" resultType="io.metersphere.dto.ProjectDTO">
select p.id, p.workspace_id, p.name, p.description, p.update_time,
p.create_time, w.id as workspaceId, w.name as workspaceName, p.tapd_id, p.jira_key
from project p
join workspace w on p.workspace_id = w.id
p.create_time, w.id as workspaceId, w.name as workspaceName, p.tapd_id, p.jira_key
from project p
join workspace w on p.workspace_id = w.id
<where>
<if test="proRequest.name != null and proRequest.name != ''">
and p.name like #{proRequest.name, jdbcType=VARCHAR}
......@@ -28,4 +28,22 @@
where workspace_id = #{workspaceId}
</select>
<update id="removeIssuePlatform">
update project
<set>
<if test="platform == 'Jira'">
jira_key = null
</if>
<if test="platform == 'Tapd'">
tapd_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)
</update>
</mapper>
\ No newline at end of file
......@@ -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<ServiceIntegration> getAll(String orgId) {
......
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.*;
......
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<MultiValueMap> requestEntity = new HttpEntity<>(headers);
RestTemplate restTemplate = new RestTemplate();
//post
ResponseEntity<String> responseEntity = null;
ResponseEntity<String> 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> issues = extIssuesMapper.getIssues(caseId, IssuesManagePlatform.Tapd.toString());
List<String> issuesIds = issues.stream().map(issue -> issue.getId()).collect(Collectors.toList());
List<String> 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> issues = extIssuesMapper.getIssues(caseId, IssuesManagePlatform.Jira.toString());
List<String> issuesIds = issues.stream().map(issue -> issue.getId()).collect(Collectors.toList());
List<String> issuesIds = issues.stream().map(Issues::getId).collect(Collectors.toList());
issuesIds.forEach(issuesId -> {
Issues dto = getJiraIssues(headers, url, issuesId);
if (StringUtils.isBlank(dto.getId())) {
......
<template>
<el-card class="header-title">
<div v-loading="result.loading">
<el-card class="header-title" v-loading="result.loading">
<div>
<div>{{$t('organization.select_defect_platform')}}</div>
<el-radio-group v-model="platform" style="margin-top: 10px" @change="change">
<el-radio v-for="(item, index) in platforms" :key="index" :label="item.value" size="small">
......@@ -26,12 +26,12 @@
</div>
<div style="margin-left: 100px">
<el-button type="primary" size="small" :disabled="!show" @click="testConnection">{{$t('ldap.test_connect')}}
<el-button type="primary" size="mini" :disabled="!show" @click="testConnection">{{$t('ldap.test_connect')}}
</el-button>
<el-button v-if="showEdit" size="small" @click="edit">{{$t('commons.edit')}}</el-button>
<el-button type="primary" v-if="showSave" size="small" @click="save('form')">{{$t('commons.save')}}</el-button>
<el-button v-if="showCancel" size="small" @click="cancelEdit">取消编辑</el-button>
<el-button type="info" size="small" @click="cancelIntegration('form')" :disabled="!show">
<el-button v-if="showEdit" size="mini" @click="edit">{{$t('commons.edit')}}</el-button>
<el-button type="primary" v-if="showSave" size="mini" @click="save('form')">{{$t('commons.save')}}</el-button>
<el-button v-if="showCancel" size="mini" @click="cancelEdit">取消编辑</el-button>
<el-button type="info" size="mini" @click="cancelIntegration('form')" :disabled="!show">
取消集成
</el-button>
</div>
......@@ -54,7 +54,7 @@
import {getCurrentUser} from "../../../../common/js/utils";
export default {
name: "DefectManagement",
name: "IssuesManagement",
data() {
return {
form: {},
......@@ -195,7 +195,7 @@
});
},
testConnection() {
this.$get("issues/auth/" + this.platform, () => {
this.result = this.$get("issues/auth/" + this.platform, () => {
this.$success("验证通过!");
});
}
......
......@@ -10,7 +10,7 @@
<script>
import DefectManagement from "./DefectManagement";
import DefectManagement from "./IssuesManagement";
export default {
name: "ServiceIntegration",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册