fix: jira勾选模板缺陷图片显示
--bug=1009500 --user=陈建星 【github#9176】【对接jira】创建jira缺陷时,ms系统里面的描述字段粘贴图片,但jira系统没有展示图片出来 https://www.tapd.cn/55049933/s/10979000
This commit is contained in:
parent
5d61a53691
commit
2292cf08b0
|
@ -498,7 +498,12 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform {
|
|||
Set<String> ids = issueFields.stream().map(i -> ((JSONObject) i).getString("id")).collect(Collectors.toSet());
|
||||
JSONArray defaultFields = JSONArray.parseArray(defaultCustomField);
|
||||
defaultFields.forEach(item -> { // 如果自定义字段里没有模板新加的字段,就把新字段加上
|
||||
if (!ids.contains(((JSONObject) item).getString("id"))) {
|
||||
String id = ((JSONObject) item).getString("id");
|
||||
if (StringUtils.isBlank(id)) {
|
||||
id = ((JSONObject) item).getString("key");
|
||||
((JSONObject) item).put("id", id);
|
||||
}
|
||||
if (!ids.contains(id)) {
|
||||
issueFields.add(item);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -141,12 +141,12 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
|
||||
setUserConfig();
|
||||
Project project = getProject();
|
||||
List<File> imageFiles = getImageFiles(issuesRequest);
|
||||
JSONObject addJiraIssueParam = buildUpdateParam(issuesRequest, getIssueType(project.getIssueConfig()), project.getJiraKey());
|
||||
|
||||
JiraAddIssueResponse result = jiraClientV2.addIssue(JSONObject.toJSONString(addJiraIssueParam));
|
||||
JiraIssue issues = jiraClientV2.getIssues(result.getId());
|
||||
|
||||
List<File> imageFiles = getImageFiles(issuesRequest.getDescription());
|
||||
|
||||
imageFiles.forEach(img -> jiraClientV2.uploadAttachment(result.getKey(), img));
|
||||
|
||||
String status = getStatus(issues.getFields());
|
||||
|
@ -168,6 +168,24 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
return super.getProject(this.projectId, Project::getJiraKey);
|
||||
}
|
||||
|
||||
private List<File> getImageFiles(IssuesUpdateRequest issuesRequest) {
|
||||
List<File> files = getImageFiles(issuesRequest.getDescription());
|
||||
List<CustomFieldItemDTO> customFields = CustomFieldService.getCustomFields(issuesRequest.getCustomFields());
|
||||
customFields.forEach(item -> {
|
||||
String fieldName = item.getCustomData();
|
||||
if (StringUtils.isNotBlank(fieldName)) {
|
||||
if (item.getValue() != null) {
|
||||
if (StringUtils.isNotBlank(item.getType())) {
|
||||
if (StringUtils.equalsAny(item.getType(), "richText")) {
|
||||
files.addAll(getImageFiles(item.getValue().toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return files;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数比较特殊,需要特别处理
|
||||
* @param fields
|
||||
|
@ -294,6 +312,11 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
}
|
||||
fields.put(fieldName, attr);
|
||||
}
|
||||
} else if (StringUtils.equalsAny(item.getType(), "richText")) {
|
||||
fields.put(fieldName, removeImage(item.getValue().toString()));
|
||||
if (fieldName.equals("description")) {
|
||||
issuesRequest.setDescription(item.getValue().toString());
|
||||
}
|
||||
} else {
|
||||
fields.put(fieldName, item.getValue());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue