Commit 87fda5b9 authored by 孙长纪's avatar 孙长纪

增加查询最近项目的变动查询api

parent 995b7c6f
...@@ -15,7 +15,7 @@ sourceCompatibility = 1.8 ...@@ -15,7 +15,7 @@ sourceCompatibility = 1.8
targetCompatibility = 1.8 targetCompatibility = 1.8
group = 'cn.com.duiba.tool' group = 'cn.com.duiba.tool'
version = '1.3.7-SNAPSHOT' version = '1.3.8'
repositories { repositories {
mavenLocal() mavenLocal()
......
...@@ -2,18 +2,63 @@ package org.gitlab.api; ...@@ -2,18 +2,63 @@ package org.gitlab.api;
import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import org.gitlab.api.http.GitlabHTTPRequestor; import org.gitlab.api.http.GitlabHTTPRequestor;
import org.gitlab.api.http.Query; import org.gitlab.api.http.Query;
import org.gitlab.api.models.*; import org.gitlab.api.models.CommitComment;
import org.gitlab.api.models.CreateGroupRequest;
import java.io.*; import org.gitlab.api.models.CreateUserRequest;
import org.gitlab.api.models.DeployKey;
import org.gitlab.api.models.GitLabTimeTracking;
import org.gitlab.api.models.GitabProjectLatelyChangeQry;
import org.gitlab.api.models.GitlabAccessLevel;
import org.gitlab.api.models.GitlabAward;
import org.gitlab.api.models.GitlabBranch;
import org.gitlab.api.models.GitlabBuildVariable;
import org.gitlab.api.models.GitlabCommit;
import org.gitlab.api.models.GitlabCommitComparison;
import org.gitlab.api.models.GitlabCommitDiff;
import org.gitlab.api.models.GitlabCommitStatus;
import org.gitlab.api.models.GitlabEmailonPushProperties;
import org.gitlab.api.models.GitlabGroup;
import org.gitlab.api.models.GitlabGroupMember;
import org.gitlab.api.models.GitlabIssue;
import org.gitlab.api.models.GitlabJiraProperties;
import org.gitlab.api.models.GitlabJob;
import org.gitlab.api.models.GitlabLabel;
import org.gitlab.api.models.GitlabMergeRequest;
import org.gitlab.api.models.GitlabMergeRequestApprovals;
import org.gitlab.api.models.GitlabMilestone;
import org.gitlab.api.models.GitlabNamespace;
import org.gitlab.api.models.GitlabNote;
import org.gitlab.api.models.GitlabProject;
import org.gitlab.api.models.GitlabProjectHook;
import org.gitlab.api.models.GitlabProjectMember;
import org.gitlab.api.models.GitlabProjectMerges;
import org.gitlab.api.models.GitlabRepositoryFile;
import org.gitlab.api.models.GitlabRepositoryTree;
import org.gitlab.api.models.GitlabSSHKey;
import org.gitlab.api.models.GitlabServiceEmailOnPush;
import org.gitlab.api.models.GitlabServiceJira;
import org.gitlab.api.models.GitlabSession;
import org.gitlab.api.models.GitlabSimpleRepositoryFile;
import org.gitlab.api.models.GitlabSystemHook;
import org.gitlab.api.models.GitlabTag;
import org.gitlab.api.models.GitlabTrigger;
import org.gitlab.api.models.GitlabUpload;
import org.gitlab.api.models.GitlabUser;
import org.gitlab.api.models.GitlabVersion;
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.net.Proxy; import java.net.Proxy;
import java.net.URL; import java.net.URL;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -2994,4 +3039,26 @@ public class GitlabAPI { ...@@ -2994,4 +3039,26 @@ public class GitlabAPI {
String tailUrl = GitlabProject.URL + "/" + projectId + "/" + GitlabMergeRequest.URL + "/" + mergeRequestId + "/time_stats"; String tailUrl = GitlabProject.URL + "/" + projectId + "/" + GitlabMergeRequest.URL + "/" + mergeRequestId + "/time_stats";
return retrieve().to(tailUrl, GitLabTimeTracking.class); return retrieve().to(tailUrl, GitLabTimeTracking.class);
} }
/**
* 查询项目分支下最近一次变动信息
*
* @param qry 查询参数
*/
public List<GitlabProjectMerges> getLatelyMergeInfo(GitabProjectLatelyChangeQry qry) throws IOException {
Query query = new Pagination()
.withPage(qry.getPage())
.withPerPage(qry.getPrePage()).asQuery();
query.appendIf("state", qry.getState())
.append("target_branch", qry.getTargetBranch());
String tailUrl = GitlabProject.URL + "/" + qry.getId() + GitlabMergeRequest.URL + query;
GitlabProjectMerges[] requests = retrieve().to(tailUrl, GitlabProjectMerges[].class);
if(requests == null || requests.length == 0) {
return Collections.emptyList();
}
return Arrays.asList(requests);
}
} }
package org.gitlab.api.models;
/**
* http://gitlab2.dui88.com/help/api/merge_requests.md
* List project merge requests
* 查询最近一个项目一个分支下最新代码变动查询条件封装对象
*
* Created by sunchangji on 2018/12/5.
*/
public class GitabProjectLatelyChangeQry {
/**
* 项目id
*/
private Integer id;
/**
* Return all merge requests or just those that are opened, closed, locked, or merged
*/
private String state = "merged";
/**
* Return merge requests with the given target branch
*/
private String targetBranch;
/**
* 分页信息
*/
private Integer page = 1;
private Integer prePage = 1;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getTargetBranch() {
return targetBranch;
}
public void setTargetBranch(String targetBranch) {
this.targetBranch = targetBranch;
}
public Integer getPage() {
return page;
}
public void setPage(Integer page) {
this.page = page;
}
public Integer getPrePage() {
return prePage;
}
public void setPrePage(Integer prePage) {
this.prePage = prePage;
}
}
package org.gitlab.api.models;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Date;
/**
* http://gitlab2.dui88.com/help/api/merge_requests.md
* project merge requests
* Created by sunchangji on 2018/12/5.
*/
public class GitlabProjectMerges {
@JsonProperty("project_id")
private Integer projectId;
private String state;
private String title;
private String description;
@JsonProperty("merged_at")
private Date mergedAt;
@JsonProperty("created_at")
private Date createdAt;
@JsonProperty("updated_at")
private Date updatedAt;
@JsonProperty("target_branch")
private String targetBranch;
@JsonProperty("source_branch")
private String sourceBranch;
@JsonProperty("source_project_id")
private Integer sourceProjectId;
@JsonProperty("target_project_id")
private Integer targetProjectId;
/**
* 合并人信息,就是这个变动合并时谁合并的
*/
@JsonProperty("merged_by")
private GitlabUserSimpleInfo mergedBy;
/**
* 修改代码人员信息,也是提交合并请求人的信息
*/
private GitlabUserSimpleInfo author;
/**
* 指订审核的人员信息
*/
private GitlabUserSimpleInfo assignee;
public Integer getProjectId() {
return projectId;
}
public void setProjectId(Integer projectId) {
this.projectId = projectId;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Date getMergedAt() {
return mergedAt;
}
public void setMergedAt(Date mergedAt) {
this.mergedAt = mergedAt;
}
public Date getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
public Date getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(Date updatedAt) {
this.updatedAt = updatedAt;
}
public String getTargetBranch() {
return targetBranch;
}
public void setTargetBranch(String targetBranch) {
this.targetBranch = targetBranch;
}
public String getSourceBranch() {
return sourceBranch;
}
public void setSourceBranch(String sourceBranch) {
this.sourceBranch = sourceBranch;
}
public Integer getSourceProjectId() {
return sourceProjectId;
}
public void setSourceProjectId(Integer sourceProjectId) {
this.sourceProjectId = sourceProjectId;
}
public Integer getTargetProjectId() {
return targetProjectId;
}
public void setTargetProjectId(Integer targetProjectId) {
this.targetProjectId = targetProjectId;
}
public GitlabUserSimpleInfo getMergedBy() {
return mergedBy;
}
public void setMergedBy(GitlabUserSimpleInfo mergedBy) {
this.mergedBy = mergedBy;
}
public GitlabUserSimpleInfo getAuthor() {
return author;
}
public void setAuthor(GitlabUserSimpleInfo author) {
this.author = author;
}
public GitlabUserSimpleInfo getAssignee() {
return assignee;
}
public void setAssignee(GitlabUserSimpleInfo assignee) {
this.assignee = assignee;
}
}
package org.gitlab.api.models;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* Created by sunchangji on 2018/12/5.
*/
public class GitlabUserSimpleInfo {
private Integer id;
private String name;
private String username;
private String state;
@JsonProperty("avatar_url")
private String avatarUrl;
@JsonProperty("web_url")
private String webUrl;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getAvatarUrl() {
return avatarUrl;
}
public void setAvatarUrl(String avatarUrl) {
this.avatarUrl = avatarUrl;
}
public String getWebUrl() {
return webUrl;
}
public void setWebUrl(String webUrl) {
this.webUrl = webUrl;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment