|
|
@@ -32,7 +32,7 @@ public class CoderService implements SubsystemService {
|
|
|
requestBody.put("price", courseVO.getPrice().toString());
|
|
|
String result = null;
|
|
|
try {
|
|
|
- result = httpService.sendPost(uri, requestBody, token);
|
|
|
+ result = httpService.sendPost(uri, requestBody, null, token);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
@@ -43,15 +43,15 @@ public class CoderService implements SubsystemService {
|
|
|
public void deleteCourse(CourseVO courseVO) {
|
|
|
}
|
|
|
|
|
|
- public JSONObject getAllCourse(int page, int limit){
|
|
|
+ public JSONObject getAllCourse(int page, int limit) {
|
|
|
String token = httpService.getToken();
|
|
|
List<NameValuePair> params = new ArrayList<>();
|
|
|
params.add(new BasicNameValuePair("page", String.valueOf(page)));
|
|
|
params.add(new BasicNameValuePair("limit", String.valueOf(limit)));
|
|
|
String result = null;
|
|
|
try {
|
|
|
- result = httpService.sendGet(coderUrlPrefix+"/course", params, token);
|
|
|
- } catch (Exception e){
|
|
|
+ result = httpService.sendGet(coderUrlPrefix + "/course", params, token);
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return JSON.parseObject(result);
|
|
|
@@ -140,7 +140,7 @@ public class CoderService implements SubsystemService {
|
|
|
requestBody.put("code", code);
|
|
|
String result = null;
|
|
|
try {
|
|
|
- result = httpService.sendPost(uri, requestBody, token);
|
|
|
+ result = httpService.sendPost(uri, requestBody, null, token);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
@@ -149,10 +149,11 @@ public class CoderService implements SubsystemService {
|
|
|
|
|
|
/**
|
|
|
* 获取Coder题目
|
|
|
- * @param page 页号
|
|
|
- * @param limit 页容量
|
|
|
+ *
|
|
|
+ * @param page 页号
|
|
|
+ * @param limit 页容量
|
|
|
* @param typeStr 题目类型(固定格式的字符串)
|
|
|
- * @param name 搜索内容
|
|
|
+ * @param name 搜索内容
|
|
|
* @return Json格式数据
|
|
|
*/
|
|
|
public JSONObject retrievePageProblem(int page, int limit, String typeStr, String name) {
|
|
|
@@ -164,8 +165,8 @@ public class CoderService implements SubsystemService {
|
|
|
params.add(new BasicNameValuePair("name", String.valueOf(name)));
|
|
|
String result = null;
|
|
|
try {
|
|
|
- result = httpService.sendGet(coderUrlPrefix+"/problem", params, token);
|
|
|
- }catch (Exception e){
|
|
|
+ result = httpService.sendGet(coderUrlPrefix + "/problem", params, token);
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return JSON.parseObject(result);
|
|
|
@@ -173,16 +174,17 @@ public class CoderService implements SubsystemService {
|
|
|
|
|
|
/**
|
|
|
* 创建Coder考试
|
|
|
+ *
|
|
|
* @param examDTO 考试对象
|
|
|
* @return 返回Json格式数据,前端自行处理。TODO 各个子系统返回的数据,后端进行处理,统一返回格式化数据
|
|
|
*/
|
|
|
- public JSONObject createCoderExam(JSONObject examDTO){
|
|
|
+ public JSONObject createCoderExam(JSONObject examDTO) {
|
|
|
String token = httpService.getToken();
|
|
|
JSONObject requestBody = new JSONObject(examDTO);
|
|
|
String result = null;
|
|
|
try {
|
|
|
- result = httpService.sendPost(coderUrlPrefix+"/exam", requestBody, token);
|
|
|
- } catch (Exception e){
|
|
|
+ result = httpService.sendPost(coderUrlPrefix + "/exam", requestBody, null, token);
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return JSON.parseObject(result);
|
|
|
@@ -190,6 +192,7 @@ public class CoderService implements SubsystemService {
|
|
|
|
|
|
/**
|
|
|
* 删除Coder课程
|
|
|
+ *
|
|
|
* @param examId
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -197,7 +200,7 @@ public class CoderService implements SubsystemService {
|
|
|
String token = httpService.getToken();
|
|
|
String result = null;
|
|
|
try {
|
|
|
- result = httpService.sendDelete(coderUrlPrefix+"/exam/"+examId, null, token);
|
|
|
+ result = httpService.sendDelete(coderUrlPrefix + "/exam/" + examId, null, token);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
@@ -206,6 +209,7 @@ public class CoderService implements SubsystemService {
|
|
|
|
|
|
/**
|
|
|
* 更新Coder课程
|
|
|
+ *
|
|
|
* @param examId
|
|
|
* @param examDTO
|
|
|
* @return
|
|
|
@@ -214,7 +218,7 @@ public class CoderService implements SubsystemService {
|
|
|
String token = httpService.getToken();
|
|
|
String result = null;
|
|
|
try {
|
|
|
- result = httpService.sendPut(coderUrlPrefix+"/exam/"+examId, examDTO, token);
|
|
|
+ result = httpService.sendPut(coderUrlPrefix + "/exam/" + examId, examDTO, token);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
@@ -223,6 +227,7 @@ public class CoderService implements SubsystemService {
|
|
|
|
|
|
/**
|
|
|
* 加入Coder考试
|
|
|
+ *
|
|
|
* @param examId
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -230,7 +235,7 @@ public class CoderService implements SubsystemService {
|
|
|
String token = httpService.getToken();
|
|
|
String result = null;
|
|
|
try {
|
|
|
- result = httpService.sendPost(coderUrlPrefix+"/exam/"+examId+"/join", null, token);
|
|
|
+ result = httpService.sendPost(coderUrlPrefix + "/exam/" + examId + "/join", null, null, token);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
@@ -240,6 +245,7 @@ public class CoderService implements SubsystemService {
|
|
|
|
|
|
/**
|
|
|
* 根据id获得Coder的考试信息
|
|
|
+ *
|
|
|
* @param examId
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -247,7 +253,7 @@ public class CoderService implements SubsystemService {
|
|
|
String token = httpService.getToken();
|
|
|
String result = null;
|
|
|
try {
|
|
|
- result = httpService.sendGet(coderUrlPrefix+"/exam/"+examId,null, token);
|
|
|
+ result = httpService.sendGet(coderUrlPrefix + "/exam/" + examId, null, token);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
@@ -257,6 +263,7 @@ public class CoderService implements SubsystemService {
|
|
|
|
|
|
/**
|
|
|
* 根据id获取Coder代码题
|
|
|
+ *
|
|
|
* @param problemId
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -264,7 +271,7 @@ public class CoderService implements SubsystemService {
|
|
|
String token = httpService.getToken();
|
|
|
String result = null;
|
|
|
try {
|
|
|
- result = httpService.sendGet(coderUrlPrefix+"/problem/"+problemId,null, token);
|
|
|
+ result = httpService.sendGet(coderUrlPrefix + "/problem/" + problemId, null, token);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
@@ -274,6 +281,7 @@ public class CoderService implements SubsystemService {
|
|
|
|
|
|
/**
|
|
|
* TODO 创建Coder代码题,文件上传
|
|
|
+ *
|
|
|
* @param problemDTO
|
|
|
* @param file
|
|
|
* @return
|
|
|
@@ -281,14 +289,13 @@ public class CoderService implements SubsystemService {
|
|
|
public JSONObject createCoderProblem(JSONObject problemDTO, MultipartFile file) {
|
|
|
String token = httpService.getToken();
|
|
|
String result = null;
|
|
|
- try{
|
|
|
- result = httpService.sendPostFile(coderUrlPrefix+"/problem", file, problemDTO, token);
|
|
|
+ try {
|
|
|
+ result = httpService.sendPostFile(coderUrlPrefix + "/problem", file, problemDTO, token);
|
|
|
// result = httpService.sendPostFile("http://localhost:8081/api/problem", file, problemDTO, token);
|
|
|
// HttpPost httpPost = new HttpPost("http://localhost:8081/api/problem");
|
|
|
|
|
|
|
|
|
-
|
|
|
- }catch (Exception e) {
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return JSON.parseObject(result);
|
|
|
@@ -297,6 +304,7 @@ public class CoderService implements SubsystemService {
|
|
|
|
|
|
/**
|
|
|
* 根据id删除代码题
|
|
|
+ *
|
|
|
* @param problemId
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -304,7 +312,7 @@ public class CoderService implements SubsystemService {
|
|
|
String token = httpService.getToken();
|
|
|
String result = null;
|
|
|
try {
|
|
|
- result = httpService.sendDelete(coderUrlPrefix+"/problem/"+problemId, null, token);
|
|
|
+ result = httpService.sendDelete(coderUrlPrefix + "/problem/" + problemId, null, token);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
@@ -314,6 +322,7 @@ public class CoderService implements SubsystemService {
|
|
|
|
|
|
/**
|
|
|
* 更新Coder代码题
|
|
|
+ *
|
|
|
* @param problemId
|
|
|
* @param path
|
|
|
* @param file
|
|
|
@@ -323,7 +332,7 @@ public class CoderService implements SubsystemService {
|
|
|
String token = httpService.getToken();
|
|
|
String result = null;
|
|
|
try {
|
|
|
- result = httpService.sendPutFile(coderUrlPrefix+"/problem/"+problemId, file, path, token);
|
|
|
+ result = httpService.sendPutFile(coderUrlPrefix + "/problem/" + problemId, file, path, token);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
@@ -333,6 +342,7 @@ public class CoderService implements SubsystemService {
|
|
|
|
|
|
/**
|
|
|
* 获取代码题的具体文件信息
|
|
|
+ *
|
|
|
* @param problemId
|
|
|
* @param filename
|
|
|
* @return
|
|
|
@@ -343,7 +353,7 @@ public class CoderService implements SubsystemService {
|
|
|
params.add(new BasicNameValuePair("name", String.valueOf(filename)));
|
|
|
String result = null;
|
|
|
try {
|
|
|
- result = httpService.sendGet(coderUrlPrefix+"/problem/"+problemId+"/file", params,token);
|
|
|
+ result = httpService.sendGet(coderUrlPrefix + "/problem/" + problemId + "/file", params, token);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
@@ -353,6 +363,7 @@ public class CoderService implements SubsystemService {
|
|
|
|
|
|
/**
|
|
|
* 根据id获取考试结果
|
|
|
+ *
|
|
|
* @param examId
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -360,8 +371,8 @@ public class CoderService implements SubsystemService {
|
|
|
String token = httpService.getToken();
|
|
|
String result = null;
|
|
|
try {
|
|
|
- result = httpService.sendGet(coderUrlPrefix+"/exam/"+examId+"/result", null, token);
|
|
|
- }catch (Exception e) {
|
|
|
+ result = httpService.sendGet(coderUrlPrefix + "/exam/" + examId + "/result", null, token);
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return JSON.parseObject(result);
|
|
|
@@ -369,6 +380,7 @@ public class CoderService implements SubsystemService {
|
|
|
|
|
|
/**
|
|
|
* 根据id获取某个结果的详细信息
|
|
|
+ *
|
|
|
* @param resultId
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -376,7 +388,7 @@ public class CoderService implements SubsystemService {
|
|
|
String token = httpService.getToken();
|
|
|
String result = null;
|
|
|
try {
|
|
|
- result = httpService.sendGet(coderUrlPrefix+"/result/"+resultId, null, token);
|
|
|
+ result = httpService.sendGet(coderUrlPrefix + "/result/" + resultId, null, token);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
@@ -385,6 +397,7 @@ public class CoderService implements SubsystemService {
|
|
|
|
|
|
/**
|
|
|
* 根据id获取某次提交的具体信息
|
|
|
+ *
|
|
|
* @param commitId
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -392,7 +405,7 @@ public class CoderService implements SubsystemService {
|
|
|
String token = httpService.getToken();
|
|
|
String result = null;
|
|
|
try {
|
|
|
- result = httpService.sendGet(coderUrlPrefix+"/commit/"+commitId, null, token);
|
|
|
+ result = httpService.sendGet(coderUrlPrefix + "/commit/" + commitId, null, token);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
@@ -401,6 +414,7 @@ public class CoderService implements SubsystemService {
|
|
|
|
|
|
/**
|
|
|
* 根据id获取某次记录的具体信息
|
|
|
+ *
|
|
|
* @param recordId
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -408,7 +422,7 @@ public class CoderService implements SubsystemService {
|
|
|
String token = httpService.getToken();
|
|
|
String result = null;
|
|
|
try {
|
|
|
- result = httpService.sendGet(coderUrlPrefix+"/record/"+recordId, null, token);
|
|
|
+ result = httpService.sendGet(coderUrlPrefix + "/record/" + recordId, null, token);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
@@ -420,7 +434,7 @@ public class CoderService implements SubsystemService {
|
|
|
String token = httpService.getToken();
|
|
|
String result = null;
|
|
|
try {
|
|
|
- result = httpService.sendGet(coderUrlPrefix+"/exam/"+examId+"/showConsole", null, token);
|
|
|
+ result = httpService.sendGet(coderUrlPrefix + "/exam/" + examId + "/showConsole", null, token);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
@@ -434,7 +448,7 @@ public class CoderService implements SubsystemService {
|
|
|
// JSONObject requestBody = new JSONObject();
|
|
|
// requestBody.put("showConsole", showConsole);
|
|
|
try {
|
|
|
- result = httpService.sendPost(coderUrlPrefix+"/exam/"+examId+"/showConsole?showConsole="+showConsole, null, token);
|
|
|
+ result = httpService.sendPost(coderUrlPrefix + "/exam/" + examId + "/showConsole?showConsole=" + showConsole, null, null, token);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|