fix: 企业版用户同步jira缺陷缺少部分字段

This commit is contained in:
chenjianxing 2022-04-26 18:44:25 +08:00 committed by 刘瑞斌
parent 0292e485f6
commit f95263176f
3 changed files with 17 additions and 16 deletions

View File

@ -27,9 +27,6 @@ import io.metersphere.track.service.IssuesService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.commonmark.node.Node;
import org.commonmark.parser.Parser;
import org.commonmark.renderer.html.HtmlRenderer;
import org.springframework.web.client.HttpClientErrorException;
import java.io.File;
@ -97,16 +94,18 @@ public class JiraPlatform extends AbstractIssuePlatform {
// 附件处理
Map<String, String> fileContentMap = new HashMap<>();
for (int i = 0; i < attachments.size(); i++) {
JSONObject attachment = attachments.getJSONObject(i);
String filename = attachment.getString("filename");
String content = attachment.getString("content");
if (StringUtils.equals(attachment.getString("mimeType"), "image/jpeg")) {
String contentUrl = "![" + filename + "](" + content + ")";
fileContentMap.put(filename, contentUrl);
} else {
String contentUrl = "附件[" + filename + "]下载地址:" + content;
fileContentMap.put(filename, contentUrl);
if (CollectionUtils.isNotEmpty(attachments)) {
for (int i = 0; i < attachments.size(); i++) {
JSONObject attachment = attachments.getJSONObject(i);
String filename = attachment.getString("filename");
String content = attachment.getString("content");
if (StringUtils.equals(attachment.getString("mimeType"), "image/jpeg")) {
String contentUrl = "![" + filename + "](" + content + ")";
fileContentMap.put(filename, contentUrl);
} else {
String contentUrl = "附件[" + filename + "]下载地址:" + content;
fileContentMap.put(filename, contentUrl);
}
}
}
@ -137,7 +136,7 @@ public class JiraPlatform extends AbstractIssuePlatform {
JSONObject statusObj = (JSONObject) fields.get("status");
if (statusObj != null) {
JSONObject statusCategory = (JSONObject) statusObj.get("statusCategory");
return statusCategory.getString("name");
return statusObj.getString("name") == null ? statusCategory.getString("name") : statusObj.getString("name");
}
return "";
}
@ -292,7 +291,7 @@ public class JiraPlatform extends AbstractIssuePlatform {
if (StringUtils.isNotBlank(issuesRequest.getDescription())) {
desc = dealWithImage(issuesRequest.getDescription());
}
fields.put("project", project);
project.put("key", jiraKey);

View File

@ -229,7 +229,7 @@ public abstract class JiraAbstractClient extends BaseClient {
public JiraIssueListResponse getProjectIssues(int startAt, int maxResults, String projectKey, String issueType) {
ResponseEntity<String> responseEntity;
responseEntity = restTemplate.exchange(getBaseUrl() + "/search?startAt={1}&maxResults={2}&jql=project={3}+AND+issuetype={4}&fields=status,assignee,summary,created,updated,attachment,description",
responseEntity = restTemplate.exchange(getBaseUrl() + "/search?startAt={1}&maxResults={2}&jql=project={3}+AND+issuetype={4}",
HttpMethod.GET, getAuthHttpEntity(), String.class, startAt, maxResults, projectKey, issueType);
return (JiraIssueListResponse)getResultForObject(JiraIssueListResponse.class, responseEntity);
}

View File

@ -300,3 +300,5 @@ ALTER TABLE `api_scenario_reference_id` ADD INDEX index_method ( `method` );
ALTER TABLE `api_scenario` ADD INDEX index_project_id ( `project_id`);
ALTER TABLE share_info ADD lang varchar(10) NULL;
UPDATE system_parameter SET param_value = 'http://grid-local:4444' WHERE param_key = 'base.selenium.docker.url';