|
@@ -13,6 +13,9 @@ import org.springframework.stereotype.Service;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * @author wind
|
|
|
|
|
+ */
|
|
|
@Service
|
|
@Service
|
|
|
public class DevcloudServiceImpl implements DevcloudService {
|
|
public class DevcloudServiceImpl implements DevcloudService {
|
|
|
private final String devcloudUri = "https://devcloud-server.seec.seecoder.cn";
|
|
private final String devcloudUri = "https://devcloud-server.seec.seecoder.cn";
|
|
@@ -84,7 +87,7 @@ public class DevcloudServiceImpl implements DevcloudService {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public JSONObject createProject(JSONObject project) {
|
|
public JSONObject createProject(JSONObject project) {
|
|
|
- JSONObject result = null;
|
|
|
|
|
|
|
+ JSONObject result;
|
|
|
try {
|
|
try {
|
|
|
result = JSONObject.parseObject(
|
|
result = JSONObject.parseObject(
|
|
|
httpService.sendPost(
|
|
httpService.sendPost(
|
|
@@ -103,4 +106,29 @@ public class DevcloudServiceImpl implements DevcloudService {
|
|
|
throw CustomErrorException.devcloudError(result.toString());
|
|
throw CustomErrorException.devcloudError(result.toString());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public JSONObject forkProject(Integer projectId, String name) {
|
|
|
|
|
+ JSONObject result;
|
|
|
|
|
+ JSONObject requestBody = new JSONObject();
|
|
|
|
|
+ requestBody.put("projectId", projectId);
|
|
|
|
|
+ requestBody.put("name", name);
|
|
|
|
|
+ try {
|
|
|
|
|
+ result = JSONObject.parseObject(
|
|
|
|
|
+ httpService.sendPost(
|
|
|
|
|
+ devcloudUri + "/fork",
|
|
|
|
|
+ requestBody,
|
|
|
|
|
+ httpService.getToken()
|
|
|
|
|
+ )
|
|
|
|
|
+ );
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ assert result != null;
|
|
|
|
|
+ if (result.containsKey("code") && result.getInteger("code") == 200) {
|
|
|
|
|
+ return result.getJSONObject("data");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ throw CustomErrorException.devcloudError(result.toString());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|