添加平台根据login获取项目接口/单测

This commit is contained in:
623756217 2023-03-04 13:59:28 +08:00
parent 14387d4198
commit fb57d71111
2 changed files with 25 additions and 0 deletions

View File

@ -14,6 +14,7 @@ import org.springframework.web.client.RestTemplate;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
@Component
public class GitLinkApi {
@ -35,6 +36,23 @@ public class GitLinkApi {
return headParams;
}
/**
* 调用平台接口获取用户项目列表
*
* @param uid 用户uid
* @param params 用户login
* @param category 需传入created默认为全部项目 join: 参与项目, created: 创建项目, manage: 管理项目, watched: 关注项目, forked: 复刻项目
* @return Response 统一响应对象
*/
public Response getProjectsByLogin(Integer uid, Object[] params, String category){
Map<String, String> inputParams = new HashMap<>();
inputParams.put("uid", uid.toString());
if(category!=null && !Objects.isNull(category)){
inputParams.put("category", category);
}
Response response = RestTemplateUtil.httpRequest(restTemplate, HttpMethod.GET, URL+"/api/v1/", params, "/projects.json", inputParams, null ,getHeader());
return response;
}
public Response getUserByUid(Integer uid){
Map<String, String> inputParams = new HashMap<>();

View File

@ -27,6 +27,13 @@ public class GitLinkApiTest {
System.out.println(response.getData());
}
@Test
public void getUserProTest(){
Object[] params = new Object[]{"durian"};
Response response = api.getProjectsByLogin(84993,params,"created");
System.out.println(response.getData());
}
@Test
public void activeBotAuthTest(){
Response response = api.activeBotAuth(84993,800,"auth_active");