fix: markdown旧数据图片无法显示
--bug=1009605 --user=陈建星 【测试跟踪】缺陷管理,有带图片的缺陷,console就会有报错 https://www.tapd.cn/55049933/s/1091852
This commit is contained in:
parent
b47a09f1a4
commit
b79c972da6
|
@ -68,7 +68,7 @@
|
||||||
<select id="getIssueForSync" resultType="io.metersphere.base.domain.IssuesDao">
|
<select id="getIssueForSync" resultType="io.metersphere.base.domain.IssuesDao">
|
||||||
select id,platform, platform_id
|
select id,platform, platform_id
|
||||||
from issues
|
from issues
|
||||||
where project_id = #{projectId} and platform != 'Local';
|
where project_id = #{projectId} and platform != 'Local' and (platform_status != 'delete' or platform_status is null);
|
||||||
</select>
|
</select>
|
||||||
<select id="selectForPlanReport" resultType="io.metersphere.track.dto.PlanReportIssueDTO">
|
<select id="selectForPlanReport" resultType="io.metersphere.track.dto.PlanReportIssueDTO">
|
||||||
select id,status,platform_status,platform from issues where resource_id = #{planId} and ( platform_status != 'delete' or platform_status is null);
|
select id,status,platform_status,platform from issues where resource_id = #{planId} and ( platform_status != 'delete' or platform_status is null);
|
||||||
|
|
|
@ -15,7 +15,7 @@ public class ShiroUtils {
|
||||||
|
|
||||||
public static void loadBaseFilterChain(Map<String, String> filterChainDefinitionMap) {
|
public static void loadBaseFilterChain(Map<String, String> filterChainDefinitionMap) {
|
||||||
|
|
||||||
filterChainDefinitionMap.put("/resource/md/get", "anon");
|
filterChainDefinitionMap.put("/resource/md/get/**", "anon");
|
||||||
filterChainDefinitionMap.put("/*.worker.js", "anon");
|
filterChainDefinitionMap.put("/*.worker.js", "anon");
|
||||||
filterChainDefinitionMap.put("/login", "anon");
|
filterChainDefinitionMap.put("/login", "anon");
|
||||||
filterChainDefinitionMap.put("/signin", "anon");
|
filterChainDefinitionMap.put("/signin", "anon");
|
||||||
|
|
|
@ -25,6 +25,16 @@ public class ResourceController {
|
||||||
return resourceService.getMdImage(fileName);
|
return resourceService.getMdImage(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 兼容旧版本
|
||||||
|
* @param fileName
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/md/get/{fileName}")
|
||||||
|
public ResponseEntity<FileSystemResource> getFileCompatible(@PathVariable("fileName") String fileName) {
|
||||||
|
return resourceService.getMdImage(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/md/delete/{fileName}")
|
@GetMapping("/md/delete/{fileName}")
|
||||||
public void delete(@PathVariable("fileName") String fileName) {
|
public void delete(@PathVariable("fileName") String fileName) {
|
||||||
resourceService.mdDelete(fileName);
|
resourceService.mdDelete(fileName);
|
||||||
|
|
|
@ -37,6 +37,7 @@ import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.net.URLDecoder;
|
||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
@ -314,12 +315,18 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform {
|
||||||
String result = input;
|
String result = input;
|
||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
String url = matcher.group(2);
|
String url = matcher.group(2);
|
||||||
if (url.contains("/resource/md/get/")) {
|
if (url.contains("/resource/md/get/")) { // 兼容旧数据
|
||||||
String path = url.substring(url.indexOf("/resource/md/get/"));
|
String path = url.substring(url.indexOf("/resource/md/get/"));
|
||||||
String name = path.substring(path.indexOf("/resource/md/get/") + 26);
|
String name = path.substring(path.indexOf("/resource/md/get/") + 26);
|
||||||
String mdLink = "![" + name + "](" + path + ")";
|
String mdLink = "![" + name + "](" + path + ")";
|
||||||
result = matcher.replaceFirst(mdLink);
|
result = matcher.replaceFirst(mdLink);
|
||||||
matcher = pattern.matcher(result);
|
matcher = pattern.matcher(result);
|
||||||
|
} else if(url.contains("/resource/md/get")) { //新数据走这里
|
||||||
|
String path = url.substring(url.indexOf("/resource/md/get"));
|
||||||
|
String name = path.substring(path.indexOf("/resource/md/get") + 35);
|
||||||
|
String mdLink = "![" + name + "](" + path + ")";
|
||||||
|
result = matcher.replaceFirst(mdLink);
|
||||||
|
matcher = pattern.matcher(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -336,9 +343,12 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform {
|
||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
try {
|
try {
|
||||||
String path = matcher.group(2);
|
String path = matcher.group(2);
|
||||||
if (path.contains("/resource/md/get/")) {
|
if (path.contains("/resource/md/get/")) { // 兼容旧数据
|
||||||
String name = path.substring(path.indexOf("/resource/md/get/") + 17);
|
String name = path.substring(path.indexOf("/resource/md/get/") + 17);
|
||||||
files.add(new File(FileUtils.MD_IMAGE_DIR + "/" + name));
|
files.add(new File(FileUtils.MD_IMAGE_DIR + "/" + name));
|
||||||
|
} else if (path.contains("/resource/md/get")) { // 新数据走这里
|
||||||
|
String name = path.substring(path.indexOf("/resource/md/get") + 26);
|
||||||
|
files.add(new File(FileUtils.MD_IMAGE_DIR + "/" + URLDecoder.decode(name, "UTF-8")));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogUtil.error(e.getMessage(), e);
|
LogUtil.error(e.getMessage(), e);
|
||||||
|
|
|
@ -183,10 +183,6 @@ public class TapdPlatform extends AbstractIssuePlatform {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void syncIssues(Project project, List<IssuesDao> tapdIssues) {
|
public void syncIssues(Project project, List<IssuesDao> tapdIssues) {
|
||||||
int pageNum = 1;
|
|
||||||
int limit = 50;
|
|
||||||
int count = 50;
|
|
||||||
|
|
||||||
Map<String, String> idMap = tapdIssues.stream()
|
Map<String, String> idMap = tapdIssues.stream()
|
||||||
.collect(Collectors.toMap(IssuesDao::getPlatformId, IssuesDao::getId));
|
.collect(Collectors.toMap(IssuesDao::getPlatformId, IssuesDao::getId));
|
||||||
|
|
||||||
|
@ -194,17 +190,17 @@ public class TapdPlatform extends AbstractIssuePlatform {
|
||||||
.map(IssuesDao::getPlatformId)
|
.map(IssuesDao::getPlatformId)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
if (CollectionUtils.isEmpty(ids)) {
|
if (CollectionUtils.isEmpty(ids)) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, String> statusMap = tapdClient.getStatusMap(project.getTapdId());
|
Map<String, String> statusMap = tapdClient.getStatusMap(project.getTapdId());
|
||||||
|
|
||||||
while (count == limit) {
|
int index = 0;
|
||||||
TapdGetIssueResponse result = tapdClient.getIssueForPageByIds(project.getTapdId(), pageNum, limit, ids);
|
int limit = 50;
|
||||||
|
|
||||||
|
while (index < ids.size()) {
|
||||||
|
List<String> subIds = ids.subList(index, (index + limit) > ids.size() ? ids.size() : (index + limit));
|
||||||
|
TapdGetIssueResponse result = tapdClient.getIssueForPageByIds(project.getTapdId(), 1, limit, subIds);
|
||||||
List<JSONObject> datas = result.getData();
|
List<JSONObject> datas = result.getData();
|
||||||
count = datas.size();
|
|
||||||
pageNum++;
|
|
||||||
datas.forEach(issue -> {
|
datas.forEach(issue -> {
|
||||||
JSONObject bug = issue.getJSONObject("Bug");
|
JSONObject bug = issue.getJSONObject("Bug");
|
||||||
String platformId = bug.getString("id");
|
String platformId = bug.getString("id");
|
||||||
|
@ -215,6 +211,7 @@ public class TapdPlatform extends AbstractIssuePlatform {
|
||||||
issuesMapper.updateByPrimaryKeySelective(updateIssue);
|
issuesMapper.updateByPrimaryKeySelective(updateIssue);
|
||||||
ids.remove(platformId);
|
ids.remove(platformId);
|
||||||
});
|
});
|
||||||
|
index += limit;
|
||||||
}
|
}
|
||||||
// 查不到的设置为删除
|
// 查不到的设置为删除
|
||||||
ids.forEach((id) -> {
|
ids.forEach((id) -> {
|
||||||
|
|
|
@ -134,7 +134,6 @@ public abstract class JiraAbstractClient extends BaseClient {
|
||||||
response = restTemplate.exchange(getBaseUrl() + "/issue/" + issueKey + "/attachments", HttpMethod.POST, requestEntity, String.class);
|
response = restTemplate.exchange(getBaseUrl() + "/issue/" + issueKey + "/attachments", HttpMethod.POST, requestEntity, String.class);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogUtil.error(e.getMessage(), e);
|
LogUtil.error(e.getMessage(), e);
|
||||||
MSException.throwException(e.getMessage());
|
|
||||||
}
|
}
|
||||||
System.out.println(response);
|
System.out.println(response);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue