fix: 同步jira缺陷图片没了

This commit is contained in:
chenjianxing 2021-08-27 17:16:10 +08:00 committed by jianxing
parent e89999acf2
commit 58ef571fdd
2 changed files with 18 additions and 1 deletions

View File

@ -264,6 +264,19 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform {
return input; 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) { protected String htmlImg2MsImg(String input) {
// <img src="xxx/resource/md/get/a0b19136_中心主题.png"/> -> ![中心主题.png](/resource/md/get/a0b19136_中心主题.png) // <img src="xxx/resource/md/get/a0b19136_中心主题.png"/> -> ![中心主题.png](/resource/md/get/a0b19136_中心主题.png)
String regex = "(<img\\s*src=\\\"(.*?)\\\".*?>)"; String regex = "(<img\\s*src=\\\"(.*?)\\\".*?>)";

View File

@ -309,8 +309,12 @@ public class JiraPlatform extends AbstractIssuePlatform {
issues.forEach(item -> { issues.forEach(item -> {
setConfig(); setConfig();
try { try {
IssuesWithBLOBs issuesWithBLOBs = issuesMapper.selectByPrimaryKey(item.getId());
parseIssue(item, jiraClientV2.getIssues(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); issuesMapper.updateByPrimaryKeySelective(item);
} catch (HttpClientErrorException e) { } catch (HttpClientErrorException e) {
if (e.getRawStatusCode() == 404) { if (e.getRawStatusCode() == 404) {