fix(测试跟踪): 缺陷中MD控件图片显示问题

This commit is contained in:
song-cc-rock 2022-10-13 11:51:09 +08:00 committed by jianxing
parent 5f89e8aaef
commit 5f860faefe
3 changed files with 34 additions and 5 deletions

View File

@ -16,7 +16,8 @@ public class IssueProxyResourceController {
IssueProxyResourceService issueProxyResourceService;
@GetMapping(value = "/md/get/url")
public ResponseEntity<byte[]> getFileByUrl(@RequestParam ("url") String url, @RequestParam (value = "platform", required = false) String platform) {
return issueProxyResourceService.getMdImageByUrl(url, platform);
public ResponseEntity<byte[]> getFileByUrl(@RequestParam ("url") String url, @RequestParam (value = "platform", required = false) String platform,
@RequestParam ("project_id") String projectId, @RequestParam ("workspace_id") String workspaceId) {
return issueProxyResourceService.getMdImageByUrl(url, platform, projectId, workspaceId);
}
}

View File

@ -511,6 +511,8 @@ public class IssuesService {
item.setCaseCount(caseIdSet.size());
});
buildCustomField(issues);
//处理MD图片链接内容
handleJiraIssueMdUrl(request.getWorkspaceId(), request.getProjectId(), issues);
return issues;
}
@ -538,6 +540,32 @@ public class IssuesService {
data.setFields(fields);
}
private void handleJiraIssueMdUrl(String workPlaceId, String projectId, List<IssuesDao> issues) {
issues.forEach(issue -> {
if (StringUtils.isNotEmpty(issue.getDescription()) && issue.getDescription().contains("platform=Jira&")) {
issue.setDescription(replaceJiraMdUrlParam(issue.getDescription(), workPlaceId, projectId));
}
if (StringUtils.isNotEmpty(issue.getCustomFields()) && issue.getCustomFields().contains("platform=Jira&")) {
issue.setCustomFields(replaceJiraMdUrlParam(issue.getCustomFields(), workPlaceId, projectId));
}
if (CollectionUtils.isNotEmpty(issue.getFields())) {
issue.getFields().forEach(field -> {
if (StringUtils.isNotEmpty(field.getTextValue()) && field.getTextValue().contains("platform=Jira&")) {
field.setTextValue(replaceJiraMdUrlParam(field.getTextValue(), workPlaceId, projectId));
}
if (StringUtils.isNotEmpty(field.getValue()) && field.getValue().contains("platform=Jira&")) {
field.setValue(replaceJiraMdUrlParam(field.getValue(), workPlaceId, projectId));
}
});
}
});
}
private String replaceJiraMdUrlParam(String url, String workspaceId, String projectId) {
return url.replaceAll("platform=Jira&",
"platform=Jira&project_id=" + projectId + "&workspace_id=" + workspaceId + "&");
}
private Map<String, String> getPlanMap(List<IssuesDao> issues) {
List<String> resourceIds = issues.stream().map(IssuesDao::getResourceId)
.filter(Objects::nonNull)

View File

@ -29,14 +29,14 @@ public class IssueProxyResourceService {
* @param platform
* @return
*/
public ResponseEntity<byte[]> getMdImageByUrl(String url, String platform) {
public ResponseEntity<byte[]> getMdImageByUrl(String url, String platform, String projectId, String workspaceId) {
if (url.contains("md/get/url")) {
MSException.throwException(Translator.get("invalid_parameter"));
}
if (StringUtils.isNotBlank(platform)) {
IssuesRequest issuesRequest = new IssuesRequest();
issuesRequest.setProjectId(SessionUtils.getCurrentProjectId());
issuesRequest.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
issuesRequest.setProjectId(projectId);
issuesRequest.setWorkspaceId(workspaceId);
return IssueFactory.createPlatform(platform, issuesRequest)
.proxyForGet(url, byte[].class);
}