fix(测试跟踪):缺陷管理jira平台和tapd平台和AzureDevops平台图片同步展示问题

--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
This commit is contained in:
WangXu10 2023-03-13 19:13:24 +08:00 committed by jianxing
parent 2f0b3660d5
commit 760ef4855d
2 changed files with 25 additions and 0 deletions

View File

@ -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<IssuesDao> issues) {
issues.forEach(issuesDao -> {
if(!issuesDao.getDescription().contains("filename=")){
String description = issuesDao.getDescription();
String regex = "(<img\\s*src=\\\"(.*?)\\\".*?>)";
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<IssuesDao> data) {
if (CollectionUtils.isEmpty(data)) {
return;

View File

@ -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;