fix: 提交到禅道的缺陷图片显示问题
This commit is contained in:
parent
90bd374998
commit
0cf3b55d3a
|
@ -16,11 +16,11 @@ import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
public abstract class ZentaoClient extends BaseClient {
|
public abstract class ZentaoClient extends BaseClient {
|
||||||
|
|
||||||
protected String ENDPOINT;
|
protected String ENDPOINT;
|
||||||
|
|
||||||
protected String USER_NAME;
|
protected String USER_NAME;
|
||||||
|
|
||||||
protected String PASSWD;
|
protected String PASSWD;
|
||||||
|
|
||||||
public RequestUrl requestUrl;
|
public RequestUrl requestUrl;
|
||||||
protected String url;
|
protected String url;
|
||||||
|
@ -30,7 +30,7 @@ public abstract class ZentaoClient extends BaseClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 注意 recTotal={1}&recPerPage={2}&pageID={3} 顺序不能调换,实在恶心
|
// 注意 recTotal={1}&recPerPage={2}&pageID={3} 顺序不能调换,实在恶心
|
||||||
private static final String BUG_LIST_URL="?m=bug&f=browse&productID={0}&branch=&browseType=¶m=0&orderBy=&recTotal={1}&recPerPage={2}&pageID={3}&t=json&zentaosid={4}";
|
private static final String BUG_LIST_URL = "?m=bug&f=browse&productID={0}&branch=&browseType=¶m=0&orderBy=&recTotal={1}&recPerPage={2}&pageID={3}&t=json&zentaosid={4}";
|
||||||
|
|
||||||
public String login() {
|
public String login() {
|
||||||
GetUserResponse getUserResponse = new GetUserResponse();
|
GetUserResponse getUserResponse = new GetUserResponse();
|
||||||
|
@ -76,7 +76,7 @@ public abstract class ZentaoClient extends BaseClient {
|
||||||
ResponseEntity<String> response = null;
|
ResponseEntity<String> response = null;
|
||||||
try {
|
try {
|
||||||
String bugCreate = requestUrl.getBugCreate();
|
String bugCreate = requestUrl.getBugCreate();
|
||||||
response = restTemplate.exchange(bugCreate + sessionId,
|
response = restTemplate.exchange(bugCreate + sessionId,
|
||||||
HttpMethod.POST, requestEntity, String.class);
|
HttpMethod.POST, requestEntity, String.class);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogUtil.error(e.getMessage(), e);
|
LogUtil.error(e.getMessage(), e);
|
||||||
|
@ -141,4 +141,17 @@ public abstract class ZentaoClient extends BaseClient {
|
||||||
PASSWD = config.getPassword();
|
PASSWD = config.getPassword();
|
||||||
ENDPOINT = config.getUrl();
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 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 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 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=(.*?)\"/>");
|
private static final Pattern IMG_PATTERN = Pattern.compile("m=file&f=read&fileID=(.*?)\"/>");
|
||||||
|
|
||||||
RequestUrl request = new RequestUrl();
|
RequestUrl request = new RequestUrl();
|
||||||
|
@ -34,7 +34,7 @@ public class ZentaoGetClient extends ZentaoClient {
|
||||||
request.setUserGet(getUrl(USER_GET));
|
request.setUserGet(getUrl(USER_GET));
|
||||||
request.setBuildsGet(getUrl(BUILDS_GET));
|
request.setBuildsGet(getUrl(BUILDS_GET));
|
||||||
request.setFileUpload(getUrl(FILE_UPLOAD));
|
request.setFileUpload(getUrl(FILE_UPLOAD));
|
||||||
request.setReplaceImgUrl(REPLACE_IMG_URL);
|
request.setReplaceImgUrl(getReplaceImgUrl(REPLACE_IMG_URL));
|
||||||
request.setImgPattern(IMG_PATTERN);
|
request.setImgPattern(IMG_PATTERN);
|
||||||
request.setBugUpdate(getUrl(BUG_UPDATE));
|
request.setBugUpdate(getUrl(BUG_UPDATE));
|
||||||
request.setBugDelete(getNotSuperModelUrl(BUG_DELETE));
|
request.setBugDelete(getNotSuperModelUrl(BUG_DELETE));
|
||||||
|
|
|
@ -17,7 +17,7 @@ public class ZentaoPathInfoClient extends ZentaoClient {
|
||||||
private static final String USER_GET = "/api-getModel-user-getList?zentaosid=";
|
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 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 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-(.*?)\"/>");
|
private static final Pattern IMG_PATTERN = Pattern.compile("file-read-(.*?)\"/>");
|
||||||
|
|
||||||
public ZentaoPathInfoClient(String url) {
|
public ZentaoPathInfoClient(String url) {
|
||||||
|
@ -35,7 +35,7 @@ public class ZentaoPathInfoClient extends ZentaoClient {
|
||||||
request.setUserGet(getUrl(USER_GET));
|
request.setUserGet(getUrl(USER_GET));
|
||||||
request.setBuildsGet(getUrl(BUILDS_GET));
|
request.setBuildsGet(getUrl(BUILDS_GET));
|
||||||
request.setFileUpload(getUrl(FILE_UPLOAD));
|
request.setFileUpload(getUrl(FILE_UPLOAD));
|
||||||
request.setReplaceImgUrl(REPLACE_IMG_URL);
|
request.setReplaceImgUrl(getReplaceImgUrl(REPLACE_IMG_URL));
|
||||||
request.setImgPattern(IMG_PATTERN);
|
request.setImgPattern(IMG_PATTERN);
|
||||||
request.setBugUpdate(getUrl(BUG_UPDATE));
|
request.setBugUpdate(getUrl(BUG_UPDATE));
|
||||||
request.setBugDelete(getUrl(BUG_DELETE));
|
request.setBugDelete(getUrl(BUG_DELETE));
|
||||||
|
|
Loading…
Reference in New Issue