Merge remote-tracking branch 'origin/master' into master

This commit is contained in:
Captain.B 2020-11-19 16:21:41 +08:00
commit 937963f872
2 changed files with 54 additions and 28 deletions

View File

@ -87,31 +87,39 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
String session = login(); String session = login();
HttpEntity<MultiValueMap> requestEntity = new HttpEntity<>(new HttpHeaders()); HttpEntity<MultiValueMap> requestEntity = new HttpEntity<>(new HttpHeaders());
RestTemplate restTemplate = new RestTemplate(); RestTemplate restTemplate = new RestTemplate();
ResponseEntity<String> responseEntity = restTemplate.exchange(url + "api-getModel-bug-getById-bugID={bugId}?zentaosid=" + session, try {
HttpMethod.POST, requestEntity, String.class, bugId); ResponseEntity<String> responseEntity = restTemplate.exchange(url + "api-getModel-bug-getById-bugID={bugId}?zentaosid=" + session,
String body = responseEntity.getBody(); HttpMethod.POST, requestEntity, String.class, bugId);
JSONObject obj = JSONObject.parseObject(body); String body = responseEntity.getBody();
if (obj != null) { JSONObject obj = JSONObject.parseObject(body);
JSONObject bug = obj.getJSONObject("data");
String id = bug.getString("id"); LogUtil.info("bug id is " + bugId + obj);
String title = bug.getString("title");
String description = bug.getString("steps"); if (obj != null) {
Long createTime = bug.getLong("openedDate"); JSONObject bug = obj.getJSONObject("data");
String status = bug.getString("status"); String id = bug.getString("id");
String reporter = bug.getString("openedBy"); String title = bug.getString("title");
int deleted = bug.getInteger("deleted"); String description = bug.getString("steps");
if (deleted == 1) { Long createTime = bug.getLong("openedDate");
return new Issues(); String status = bug.getString("status");
String reporter = bug.getString("openedBy");
int deleted = bug.getInteger("deleted");
if (deleted == 1) {
return new Issues();
}
Issues issues = new Issues();
issues.setId(id);
issues.setTitle(title);
issues.setDescription(description);
issues.setCreateTime(createTime);
issues.setStatus(status);
issues.setReporter(reporter);
return issues;
} }
Issues issues = new Issues(); } catch (Exception e) {
issues.setId(id); LogUtil.error("get zentao bug fail " + e.getMessage());
issues.setTitle(title);
issues.setDescription(description);
issues.setCreateTime(createTime);
issues.setStatus(status);
issues.setReporter(reporter);
return issues;
} }
return new Issues(); return new Issues();
} }
@ -150,6 +158,9 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
ResponseEntity<String> responseEntity = restTemplate.exchange(url + "api-getModel-bug-create.json?zentaosid=" + session, HttpMethod.POST, requestEntity, String.class); ResponseEntity<String> responseEntity = restTemplate.exchange(url + "api-getModel-bug-create.json?zentaosid=" + session, HttpMethod.POST, requestEntity, String.class);
String body = responseEntity.getBody(); String body = responseEntity.getBody();
JSONObject obj = JSONObject.parseObject(body); JSONObject obj = JSONObject.parseObject(body);
LogUtil.info("add zentao bug " + obj);
if (obj != null) { if (obj != null) {
JSONObject data = obj.getJSONObject("data"); JSONObject data = obj.getJSONObject("data");
String id = data.getString("id"); String id = data.getString("id");
@ -161,11 +172,16 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
testCaseIssues.setTestCaseId(testCaseId); testCaseIssues.setTestCaseId(testCaseId);
testCaseIssuesMapper.insert(testCaseIssues); testCaseIssuesMapper.insert(testCaseIssues);
// 插入缺陷表 IssuesExample issuesExample = new IssuesExample();
Issues issues = new Issues(); issuesExample.createCriteria().andIdEqualTo(id)
issues.setId(id); .andPlatformEqualTo(IssuesManagePlatform.Zentao.toString());
issues.setPlatform(IssuesManagePlatform.Zentao.toString()); if (issuesMapper.selectByExample(issuesExample).size() <= 0) {
issuesMapper.insert(issues); // 插入缺陷表
Issues issues = new Issues();
issues.setId(id);
issues.setPlatform(IssuesManagePlatform.Zentao.toString());
issuesMapper.insert(issues);
}
} }
} }
} }
@ -235,6 +251,9 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
HttpMethod.GET, requestEntity, String.class); HttpMethod.GET, requestEntity, String.class);
String body = responseEntity.getBody(); String body = responseEntity.getBody();
JSONObject obj = JSONObject.parseObject(body); JSONObject obj = JSONObject.parseObject(body);
LogUtil.info("zentao user " + obj);
JSONArray data = obj.getJSONArray("data"); JSONArray data = obj.getJSONArray("data");
List<PlatformUser> users = new ArrayList<>(); List<PlatformUser> users = new ArrayList<>();
@ -260,6 +279,9 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
HttpMethod.GET, requestEntity, String.class, projectId); HttpMethod.GET, requestEntity, String.class, projectId);
String body = responseEntity.getBody(); String body = responseEntity.getBody();
JSONObject obj = JSONObject.parseObject(body); JSONObject obj = JSONObject.parseObject(body);
LogUtil.info("zentao builds" + obj);
JSONObject data = obj.getJSONObject("data"); JSONObject data = obj.getJSONObject("data");
Map<String,Object> maps = data.getInnerMap(); Map<String,Object> maps = data.getInnerMap();

View File

@ -0,0 +1,4 @@
alter table issues drop primary key;
alter table issues
add constraint issues_pk
primary key (id, platform);