fix: 禅道影响版本没有同步
--bug=1009624 --user=陈建星 【测试跟踪】禅道平台的版本没有同步过来 https://www.tapd.cn/55049933/s/10944277
This commit is contained in:
parent
5d277e588a
commit
003db4118e
|
@ -338,32 +338,14 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
|
|||
}
|
||||
|
||||
public List<ZentaoBuild> getBuilds() {
|
||||
String session = zentaoClient.login();;
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(httpHeaders);
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
String buildGet = zentaoClient.requestUrl.getBuildsGet();
|
||||
ResponseEntity<String> responseEntity = restTemplate.exchange(buildGet + session,
|
||||
HttpMethod.GET, requestEntity, String.class, getProjectId(projectId));
|
||||
String body = responseEntity.getBody();
|
||||
JSONObject obj = JSONObject.parseObject(body);
|
||||
|
||||
LogUtil.info("zentao builds" + obj);
|
||||
|
||||
JSONObject data = obj.getJSONObject("data");
|
||||
Map<String,Object> maps = data.getInnerMap();
|
||||
|
||||
List<ZentaoBuild> list = new ArrayList<>();
|
||||
for (Map.Entry<String, Object> map : maps.entrySet()) {
|
||||
ZentaoBuild build = new ZentaoBuild();
|
||||
String id = map.getKey();
|
||||
if (StringUtils.isNotBlank(id)) {
|
||||
build.setId(map.getKey());
|
||||
build.setName((String) map.getValue());
|
||||
list.add(build);
|
||||
Map<String, String> builds = zentaoClient.getBuilds(getProjectId(projectId));
|
||||
List<ZentaoBuild> res = new ArrayList<>();
|
||||
builds.forEach((k, v) -> {
|
||||
if (StringUtils.isNotBlank(k)) {
|
||||
res.add(new ZentaoBuild(k, v));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
});
|
||||
return res;
|
||||
}
|
||||
|
||||
private String uploadFile(FileSystemResource resource) {
|
||||
|
|
|
@ -16,6 +16,8 @@ import org.springframework.http.ResponseEntity;
|
|||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class ZentaoClient extends BaseClient {
|
||||
|
||||
protected String ENDPOINT;
|
||||
|
@ -128,6 +130,22 @@ public abstract class ZentaoClient extends BaseClient {
|
|||
return JSONObject.parseObject(getIssueResponse.getData());
|
||||
}
|
||||
|
||||
public GetCreateMetaDataResponse.MetaData getCreateMetaData(String productID) {
|
||||
String sessionId = login();
|
||||
ResponseEntity<String> response = restTemplate.exchange(requestUrl.getCreateMetaData(),
|
||||
HttpMethod.GET, null, String.class, productID, sessionId);
|
||||
GetCreateMetaDataResponse getCreateMetaDataResponse = (GetCreateMetaDataResponse) getResultForObject(GetCreateMetaDataResponse.class, response);
|
||||
return JSONObject.parseObject(getCreateMetaDataResponse.getData(), GetCreateMetaDataResponse.MetaData.class);
|
||||
}
|
||||
|
||||
public JSONObject getCustomFields(String productID) {
|
||||
return getCreateMetaData(productID).getCustomFields();
|
||||
}
|
||||
|
||||
public Map<String, String> getBuilds(String productID) {
|
||||
return getCreateMetaData(productID).getBuilds();
|
||||
}
|
||||
|
||||
public JSONArray getBugsByProjectId(String projectId, int pageNum, int pageSize) {
|
||||
String sessionId = login();
|
||||
ResponseEntity<String> response = restTemplate.exchange(requestUrl.getBugList(),
|
||||
|
|
|
@ -16,6 +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 CREATE_META_DATA="?m=bug&f=create&productID={0}&t=json&zentaosid={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=(.*?)\"/>");
|
||||
// 注意 recTotal={1}&recPerPage={2}&pageID={3} 顺序不能调换,有点恶心
|
||||
|
@ -41,6 +42,7 @@ public class ZentaoGetClient extends ZentaoClient {
|
|||
request.setBugUpdate(getUrl(BUG_UPDATE));
|
||||
request.setBugDelete(getNotSuperModelUrl(BUG_DELETE));
|
||||
request.setBugList(getNotSuperModelUrl(BUG_LIST_URL));
|
||||
request.setCreateMetaData(getNotSuperModelUrl(CREATE_META_DATA));
|
||||
requestUrl = request;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ public class ZentaoPathInfoClient extends ZentaoClient {
|
|||
private static final String STORY_GET = "/api-getModel-story-getProductStories-productID={key}?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 CREATE_META_DATA="/bug-create-{0}.json";
|
||||
private static final String FILE_UPLOAD = "/api-getModel-file-saveUpload.json?zentaosid=";
|
||||
private static final String REPLACE_IMG_URL = "<img src=\"%s/file-read-$1\"/>";
|
||||
private static final Pattern IMG_PATTERN = Pattern.compile("file-read-(.*?)\"/>");
|
||||
|
@ -42,6 +43,7 @@ public class ZentaoPathInfoClient extends ZentaoClient {
|
|||
request.setBugUpdate(getUrl(BUG_UPDATE));
|
||||
request.setBugDelete(getUrl(BUG_DELETE));
|
||||
request.setBugList(getUrl(BUG_LIST_URL));
|
||||
request.setCreateMetaData(getUrl(CREATE_META_DATA));
|
||||
requestUrl = request;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,11 +5,7 @@ import lombok.Setter;
|
|||
|
||||
@Getter
|
||||
@Setter
|
||||
public class AddIssueResponse {
|
||||
private String status;
|
||||
private String md5;
|
||||
private String data;
|
||||
|
||||
public class AddIssueResponse extends ZentaoResponse {
|
||||
@Getter
|
||||
@Setter
|
||||
public static class Issue {
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package io.metersphere.track.issue.domain.zentao;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class GetCreateMetaDataResponse extends ZentaoResponse {
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class MetaData {
|
||||
private String title;
|
||||
private JSONObject users;
|
||||
private JSONObject customFields;
|
||||
private Map<String, String> builds;
|
||||
}
|
||||
}
|
|
@ -5,11 +5,7 @@ import lombok.Setter;
|
|||
|
||||
@Getter
|
||||
@Setter
|
||||
public class GetIssueResponse {
|
||||
private String status;
|
||||
private String md5;
|
||||
private String data;
|
||||
|
||||
public class GetIssueResponse extends ZentaoResponse {
|
||||
@Getter
|
||||
@Setter
|
||||
public static class Issue {
|
||||
|
|
|
@ -5,11 +5,7 @@ import lombok.Setter;
|
|||
|
||||
@Getter
|
||||
@Setter
|
||||
public class GetSessionResponse {
|
||||
private String status;
|
||||
private String data;
|
||||
// private String md5;
|
||||
|
||||
public class GetSessionResponse extends ZentaoResponse {
|
||||
@Getter
|
||||
@Setter
|
||||
public static class Session {
|
||||
|
|
|
@ -11,6 +11,7 @@ public class RequestUrl {
|
|||
private String login;
|
||||
private String sessionGet;
|
||||
private String bugCreate;
|
||||
private String createMetaData;
|
||||
private String bugUpdate;
|
||||
private String bugList;
|
||||
private String bugDelete;
|
||||
|
|
|
@ -6,4 +6,11 @@ import lombok.Data;
|
|||
public class ZentaoBuild {
|
||||
private String id;
|
||||
private String name;
|
||||
|
||||
public ZentaoBuild(String id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public ZentaoBuild() {}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
package io.metersphere.track.issue.domain.zentao;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class ZentaoResponse {
|
||||
private String status;
|
||||
private String md5;
|
||||
private String data;
|
||||
}
|
Loading…
Reference in New Issue