From 112827ce0437a5de38ab6c544959243433c80a8c Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Tue, 18 May 2021 16:37:32 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20tapd=20=E6=8F=90=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E7=BC=BA=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/metersphere/dto/CustomFieldItemDTO.java | 11 +++++++++++ .../track/issue/AbstractIssuePlatform.java | 15 ++++++++++++++- .../io/metersphere/track/issue/TapdPlatform.java | 9 +++++++++ .../workspace/template/CustomFieldFormList.vue | 2 +- frontend/src/common/js/custom_field.js | 3 ++- 5 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 backend/src/main/java/io/metersphere/dto/CustomFieldItemDTO.java diff --git a/backend/src/main/java/io/metersphere/dto/CustomFieldItemDTO.java b/backend/src/main/java/io/metersphere/dto/CustomFieldItemDTO.java new file mode 100644 index 0000000000..f462a35bb9 --- /dev/null +++ b/backend/src/main/java/io/metersphere/dto/CustomFieldItemDTO.java @@ -0,0 +1,11 @@ +package io.metersphere.dto; + +import lombok.Data; + +@Data +public class CustomFieldItemDTO { + private String id; + private String name; + private String value; + private String customData; +} diff --git a/backend/src/main/java/io/metersphere/track/issue/AbstractIssuePlatform.java b/backend/src/main/java/io/metersphere/track/issue/AbstractIssuePlatform.java index db6dbff2a2..168c9a4786 100644 --- a/backend/src/main/java/io/metersphere/track/issue/AbstractIssuePlatform.java +++ b/backend/src/main/java/io/metersphere/track/issue/AbstractIssuePlatform.java @@ -1,6 +1,10 @@ package io.metersphere.track.issue; -import io.metersphere.base.domain.*; +import com.alibaba.fastjson.JSONArray; +import io.metersphere.base.domain.IssuesWithBLOBs; +import io.metersphere.base.domain.ServiceIntegration; +import io.metersphere.base.domain.TestCaseIssues; +import io.metersphere.base.domain.TestCaseIssuesExample; import io.metersphere.base.mapper.IssuesMapper; import io.metersphere.base.mapper.TestCaseIssuesMapper; import io.metersphere.base.mapper.ext.ExtIssuesMapper; @@ -11,6 +15,7 @@ import io.metersphere.commons.utils.EncryptUtils; import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.SessionUtils; import io.metersphere.controller.request.IntegrationRequest; +import io.metersphere.dto.CustomFieldItemDTO; import io.metersphere.service.IntegrationService; import io.metersphere.service.ProjectService; import io.metersphere.track.request.testcase.IssuesRequest; @@ -28,6 +33,7 @@ import org.springframework.web.client.RestTemplate; import javax.net.ssl.SSLContext; import java.security.cert.X509Certificate; +import java.util.ArrayList; import java.util.List; import java.util.UUID; @@ -166,4 +172,11 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform { issues.setUpdateTime(System.currentTimeMillis()); issuesMapper.insert(issues); } + + protected List getCustomFields(String customFieldsStr) { + if (StringUtils.isNotBlank(customFieldsStr)) { + return JSONArray.parseArray(customFieldsStr, CustomFieldItemDTO.class); + } + return new ArrayList<>(); + } } diff --git a/backend/src/main/java/io/metersphere/track/issue/TapdPlatform.java b/backend/src/main/java/io/metersphere/track/issue/TapdPlatform.java index f20528667d..b86441d3ee 100644 --- a/backend/src/main/java/io/metersphere/track/issue/TapdPlatform.java +++ b/backend/src/main/java/io/metersphere/track/issue/TapdPlatform.java @@ -10,6 +10,7 @@ import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.SessionUtils; import io.metersphere.controller.ResultHolder; +import io.metersphere.dto.CustomFieldItemDTO; import io.metersphere.track.dto.DemandDTO; import io.metersphere.track.issue.domain.PlatformUser; import io.metersphere.track.request.testcase.IssuesRequest; @@ -150,6 +151,8 @@ public class TapdPlatform extends AbstractIssuePlatform { public void addIssue(IssuesUpdateRequest issuesRequest) { issuesRequest.setPlatform(IssuesManagePlatform.Tapd.toString()); + List customFields = getCustomFields(issuesRequest.getCustomFields()); + String url = "https://api.tapd.cn/bugs"; String testCaseId = issuesRequest.getTestCaseId(); String tapdId = getProjectId(issuesRequest.getProjectId()); @@ -173,6 +176,12 @@ public class TapdPlatform extends AbstractIssuePlatform { paramMap.add("reporter", username); paramMap.add("current_owner", usersStr); + customFields.forEach(item -> { + if (StringUtils.isNotBlank(item.getCustomData())) { + paramMap.add(item.getCustomData(), item.getValue()); + } + }); + ResultHolder result = call(url, HttpMethod.POST, paramMap); String listJson = JSON.toJSONString(result.getData()); diff --git a/frontend/src/business/components/settings/workspace/template/CustomFieldFormList.vue b/frontend/src/business/components/settings/workspace/template/CustomFieldFormList.vue index d7b786c339..eea2750802 100644 --- a/frontend/src/business/components/settings/workspace/template/CustomFieldFormList.vue +++ b/frontend/src/business/components/settings/workspace/template/CustomFieldFormList.vue @@ -32,7 +32,7 @@ - +