Browse Source

fix: eval接口更新

mjh 4 years ago
parent
commit
cf9a1f013a

+ 7 - 2
seecoder-portal-server/src/main/java/cn/seecoder/seecoderportalserver/service/ExamService.java

@@ -28,7 +28,12 @@ public class ExamService {
         return result;
     }
 
-    public JSONObject getEvalRecommendExams() {
-        return null;
+    public JSONArray getEvalRecommendExams() {
+        JSONArray result = new JSONArray();
+        for (CourseVO courseVO : courseService.getExampleCourses()) {
+            JSONObject res = evalService.getRecommendExams(courseVO.getEvalId());
+            result.addAll(res.getJSONArray("result"));
+        }
+        return result;
     }
 }

+ 11 - 0
seecoder-portal-server/src/main/java/cn/seecoder/seecoderportalserver/service/Impl/EvalService.java

@@ -128,4 +128,15 @@ public class EvalService implements SubsystemService {
         }
         return JSONObject.parseObject(result);
     }
+
+    public JSONObject getRecommendExams(int courseId){
+        String uri = "https://eval-server.seec.seecoder.cn/api/exam/recommend/" + courseId;
+        String result = null;
+        try {
+            result = httpService.sendGet(uri, new ArrayList<>(), null);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return JSONObject.parseObject(result);
+    }
 }

+ 1 - 1
seecoder-portal-server/src/main/java/cn/seecoder/seecoderportalserver/web/rest/EvalController.java

@@ -37,7 +37,7 @@ public class EvalController {
         return OkResponse.of(evalService.getTeacherExams(pageSize,pageNum,state).getJSONObject("result"));
     }
 
-    @GetMapping("/exam/recommend")
+//    @GetMapping("/exam/recommend")
     public OkResponse<JSONArray> getExampleExams() {
         return OkResponse.of(evalService.getExampleExams().getJSONArray("result"));
     }

+ 5 - 4
seecoder-portal-server/src/main/java/cn/seecoder/seecoderportalserver/web/rest/ExamController.java

@@ -2,6 +2,7 @@ package cn.seecoder.seecoderportalserver.web.rest;
 
 import cn.seecoder.seecoderportalserver.service.ExamService;
 import cn.seecoder.seecoderportalserver.utility.OkResponse;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -21,8 +22,8 @@ public class ExamController {
 //        return OkResponse.of(examService.getCoderRecommendExams());
 //    }
 
-//    @GetMapping("eval/exam/recommend")
-//    public OkResponse<JSONObject> getEvalRecommendExams() {
-//        return OkResponse.of(examService.getEvalRecommendExams());
-//    }
+    @GetMapping("eval/exam/recommend")
+    public OkResponse<JSONArray> getEvalRecommendExams() {
+        return OkResponse.of(examService.getEvalRecommendExams());
+    }
 }