fix: 提交到禅道的缺陷图片显示问题

This commit is contained in:
shiziyuan9527 2021-12-15 17:08:18 +08:00 committed by shiziyuan9527
parent 90bd374998
commit 0cf3b55d3a
3 changed files with 22 additions and 9 deletions

View File

@ -141,4 +141,17 @@ public abstract class ZentaoClient extends BaseClient {
PASSWD = config.getPassword();
ENDPOINT = config.getUrl();
}
public String getReplaceImgUrl(String replaceImgUrl) {
String baseUrl = getBaseUrl();
String[] split = baseUrl.split("/");
String suffix = split[split.length - 1];
if (!StringUtils.equalsAny(suffix, "zentao", "zentaopms", "zentaopro", "zentaobiz")) {
suffix = "";
} else {
suffix = "/" + suffix;
}
return String.format(replaceImgUrl, suffix);
}
}

View File

@ -16,7 +16,7 @@ public class ZentaoGetClient extends ZentaoClient {
private static final String USER_GET="&module=user&methodName=getList&t=json&zentaosid=";
private static final String BUILDS_GET="&module=build&methodName=getProductBuildPairs&productID={0}&zentaosid=";
private static final String FILE_UPLOAD="&module=file&methodName=saveUpload&t=json&zentaosid=";
private static final String REPLACE_IMG_URL="<img src=\"/zentao/index.php?m=file&f=read&fileID=$1\"/>";
private static final String REPLACE_IMG_URL="<img src=\"%s/index.php?m=file&f=read&fileID=$1\"/>";
private static final Pattern IMG_PATTERN = Pattern.compile("m=file&f=read&fileID=(.*?)\"/>");
RequestUrl request = new RequestUrl();
@ -34,7 +34,7 @@ public class ZentaoGetClient extends ZentaoClient {
request.setUserGet(getUrl(USER_GET));
request.setBuildsGet(getUrl(BUILDS_GET));
request.setFileUpload(getUrl(FILE_UPLOAD));
request.setReplaceImgUrl(REPLACE_IMG_URL);
request.setReplaceImgUrl(getReplaceImgUrl(REPLACE_IMG_URL));
request.setImgPattern(IMG_PATTERN);
request.setBugUpdate(getUrl(BUG_UPDATE));
request.setBugDelete(getNotSuperModelUrl(BUG_DELETE));

View File

@ -17,7 +17,7 @@ public class ZentaoPathInfoClient extends ZentaoClient {
private static final String USER_GET = "/api-getModel-user-getList?zentaosid=";
private static final String BUILDS_GET = "/api-getModel-build-getProductBuildPairs-productID={projectId}?zentaosid=";
private static final String FILE_UPLOAD = "/api-getModel-file-saveUpload.json?zentaosid=";
private static final String REPLACE_IMG_URL = "<img src=\"/zentao/file-read-$1\"/>";
private static final String REPLACE_IMG_URL = "<img src=\"%s/file-read-$1\"/>";
private static final Pattern IMG_PATTERN = Pattern.compile("file-read-(.*?)\"/>");
public ZentaoPathInfoClient(String url) {
@ -35,7 +35,7 @@ public class ZentaoPathInfoClient extends ZentaoClient {
request.setUserGet(getUrl(USER_GET));
request.setBuildsGet(getUrl(BUILDS_GET));
request.setFileUpload(getUrl(FILE_UPLOAD));
request.setReplaceImgUrl(REPLACE_IMG_URL);
request.setReplaceImgUrl(getReplaceImgUrl(REPLACE_IMG_URL));
request.setImgPattern(IMG_PATTERN);
request.setBugUpdate(getUrl(BUG_UPDATE));
request.setBugDelete(getUrl(BUG_DELETE));