From 760ef4855daa099294a1899c9c9304377f72815a Mon Sep 17 00:00:00 2001 From: WangXu10 Date: Mon, 13 Mar 2023 19:13:24 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA)?= =?UTF-8?q?=EF=BC=9A=E7=BC=BA=E9=99=B7=E7=AE=A1=E7=90=86jira=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E5=92=8Ctapd=E5=B9=B3=E5=8F=B0=E5=92=8CAzureDevops?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E5=9B=BE=E7=89=87=E5=90=8C=E6=AD=A5=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1021002 --user=王旭 【测试跟踪】ms创建缺陷到tapd-添加图片链接-tapd不显示图片 https://www.tapd.cn/55049933/s/1349109 --bug=1023065 --user=王旭 【测试跟踪】缺陷管理,关联jira平台,图片链接添加的图片和添加图片时一起编辑的文字没同步到jira https://www.tapd.cn/55049933/s/1349110 --- .../io/metersphere/service/IssuesService.java | 21 +++++++++++++++++++ .../issue/platform/AbstractIssuePlatform.java | 4 ++++ 2 files changed, 25 insertions(+) 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 71d8c5e60b..f2287485ff 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 @@ -81,6 +81,8 @@ import java.io.IOException; import java.util.*; import java.util.concurrent.TimeUnit; import java.util.function.BiConsumer; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import java.util.stream.Collectors; @Service @@ -683,10 +685,29 @@ public class IssuesService { item.setCaseIds(new ArrayList<>(caseIdSet)); item.setCaseCount(caseIdSet.size()); }); + buildDescription(issues); buildCustomField(issues); return issues; } + private void buildDescription(List issues) { + issues.forEach(issuesDao -> { + if(!issuesDao.getDescription().contains("filename=")){ + String description = issuesDao.getDescription(); + String regex = "()"; + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(description); + while (matcher.find()) { + String url = matcher.group(2); + String mdLink = "![" + UUID.randomUUID() + "](" + url + ")"; + description = matcher.replaceFirst(mdLink); + matcher = pattern.matcher(description); + } + issuesDao.setDescription(description); + } + }); + } + private void buildCustomField(List data) { if (CollectionUtils.isEmpty(data)) { return; 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 636680ce90..8d6b56668a 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 @@ -302,6 +302,10 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform { String mdLink = "![" + name + "](" + path + ")"; result = matcher.replaceFirst(mdLink); matcher = pattern.matcher(result); + } else if(url.contains("http")) { + String mdLink = "![" + UUID.randomUUID() + "](" + url + ")"; + result = matcher.replaceFirst(mdLink); + matcher = pattern.matcher(result); } } return result;