| @@ -30,6 +30,9 @@ public class GitServiceImpl implements GitService { | |||
| private String redisHost; | |||
| @Value("${spring.redis.port}") | |||
| private Integer redisPort; | |||
| @Value("${git.endpoint}") | |||
| String gitendpoint; | |||
| private static final Logger log = LoggerFactory.getLogger(GitServiceImpl.class); | |||
| @Override | |||
| @@ -43,7 +46,7 @@ public class GitServiceImpl implements GitService { | |||
| params.put("client_secret", "L3wBKTNnRo-wPen7bxR3F1myCvtVDgpWa6MnpfyWeJE"); | |||
| try { | |||
| // 发送POST请求 | |||
| String req = HttpUtils.sendPostRequest("https://www.gitlink.org.cn/oauth/token", null, JsonUtils.mapToJson(params)); | |||
| String req = HttpUtils.sendPostRequest(gitendpoint + "/oauth/token", null, JsonUtils.mapToJson(params)); | |||
| // 解析响应JSON | |||
| if (StringUtils.isEmpty(req)) { | |||
| throw new RuntimeException("终止响应内容为空。"); | |||
| @@ -55,7 +58,7 @@ public class GitServiceImpl implements GitService { | |||
| String accessToken = (String) runResMap.get("access_token"); | |||
| //通过access_token获取用户信息 | |||
| String userReq = HttpUtils.sendGetWithToken("https://www.gitlink.org.cn/api/users/get_user_info.json", null, accessToken); | |||
| String userReq = HttpUtils.sendGetWithToken(gitendpoint + "/api/users/get_user_info.json", null, accessToken); | |||
| if (StringUtils.isEmpty(userReq)) { | |||
| throw new RuntimeException("终止响应内容为空。"); | |||
| } | |||
| @@ -100,7 +103,7 @@ public class GitServiceImpl implements GitService { | |||
| @Override | |||
| public Map createProject(String token,GitProjectVo gitProjectVo) throws Exception { | |||
| String userReq = HttpUtils.sendPostWithToken("https://www.gitlink.org.cn/api/projects.json", JsonUtils.objectToJson(gitProjectVo), token); | |||
| String userReq = HttpUtils.sendPostWithToken(gitendpoint + "/api/projects.json", JsonUtils.objectToJson(gitProjectVo), token); | |||
| return JsonUtils.jsonToMap(userReq); | |||
| } | |||
| @@ -125,12 +128,12 @@ public class GitServiceImpl implements GitService { | |||
| Map<String, Object> resMap = new HashMap<>(); | |||
| resMap.put("project_id", id); | |||
| resMap.put("name", topicName); | |||
| String req = HttpUtils.sendPostWithToken("https://www.gitlink.org.cn/api/v1/project_topics.json", JsonUtils.objectToJson(resMap), token); | |||
| String req = HttpUtils.sendPostWithToken(gitendpoint + "/api/v1/project_topics.json", JsonUtils.objectToJson(resMap), token); | |||
| } | |||
| @Override | |||
| public List<Map<String, Object>> getBrancheList(String token,String owner, String projectName) throws Exception { | |||
| String req = HttpUtils.sendGetWithToken("https://www.gitlink.org.cn/api/v1/" + owner + "/" + projectName + "/branches/all.json", null, token); | |||
| String req = HttpUtils.sendGetWithToken(gitendpoint + "/api/v1/" + owner + "/" + projectName + "/branches/all.json", null, token); | |||
| // 解析响应JSON | |||
| if (StringUtils.isEmpty(req)) { | |||
| throw new RuntimeException("终止响应内容为空。"); | |||
| @@ -142,7 +145,7 @@ public class GitServiceImpl implements GitService { | |||
| @Override | |||
| public void deleteProject(String token,String owner, String projectName) throws Exception { | |||
| HttpUtils.sendDeleteRequest("https://www.gitlink.org.cn/api/" + owner + "/" + projectName + ".json", token); | |||
| HttpUtils.sendDeleteRequest(gitendpoint + "/api/" + owner + "/" + projectName + ".json", token); | |||
| } | |||
| @Override | |||
| @@ -153,12 +156,12 @@ public class GitServiceImpl implements GitService { | |||
| } catch (IOException | GitAPIException e) { | |||
| log.error("Exception occurred while creating local branch based on master",e); | |||
| } | |||
| HttpUtils.sendDeleteRequest("https://www.gitlink.org.cn/api/v1/" + owner + "/" + projectName + "/branches/" + branchName + ".json", token); | |||
| HttpUtils.sendDeleteRequest(gitendpoint + "/api/v1/" + owner + "/" + projectName + "/branches/" + branchName + ".json", token); | |||
| } | |||
| @Override | |||
| public Map getUserInfo(String token) throws Exception { | |||
| String userReq = HttpUtils.sendGetWithToken("https://www.gitlink.org.cn/api/users/get_user_info.json",null, token); | |||
| String userReq = HttpUtils.sendGetWithToken(gitendpoint + "/api/users/get_user_info.json",null, token); | |||
| if (StringUtils.isEmpty(userReq)){ | |||
| return null; | |||
| } | |||