From 58ef571fdd9cb497060d6eb0f88590d0f31eed91 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Fri, 27 Aug 2021 17:16:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=90=8C=E6=AD=A5jira=E7=BC=BA=E9=99=B7?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E6=B2=A1=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../track/issue/AbstractIssuePlatform.java | 13 +++++++++++++ .../io/metersphere/track/issue/JiraPlatform.java | 6 +++++- 2 files changed, 18 insertions(+), 1 deletion(-) 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 c0ab911d95..f3923c13a5 100644 --- a/backend/src/main/java/io/metersphere/track/issue/AbstractIssuePlatform.java +++ b/backend/src/main/java/io/metersphere/track/issue/AbstractIssuePlatform.java @@ -264,6 +264,19 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform { return input; } + protected String getImages(String input) { + String result = ""; + String regex = "(\\!\\[.*?\\]\\((.*?)\\))"; + if (StringUtils.isBlank(input)) { + return result; + } + Matcher matcher = Pattern.compile(regex).matcher(input); + while (matcher.find()) { + result += matcher.group(); + } + return result; + } + protected String htmlImg2MsImg(String input) { // -> ![中心主题.png](/resource/md/get/a0b19136_中心主题.png) String regex = "()"; diff --git a/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java b/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java index d81f034e59..fc23e2a6d7 100644 --- a/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java +++ b/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java @@ -309,8 +309,12 @@ public class JiraPlatform extends AbstractIssuePlatform { issues.forEach(item -> { setConfig(); try { + IssuesWithBLOBs issuesWithBLOBs = issuesMapper.selectByPrimaryKey(item.getId()); parseIssue(item, jiraClientV2.getIssues(item.getId())); - item.setDescription(htmlDesc2MsDesc(item.getDescription())); + String desc = htmlDesc2MsDesc(item.getDescription()); + // 保留之前上传的图片 + String images = getImages(issuesWithBLOBs.getDescription()); + item.setDescription(desc + "\n" + images); issuesMapper.updateByPrimaryKeySelective(item); } catch (HttpClientErrorException e) { if (e.getRawStatusCode() == 404) {