|
|
@@ -4,6 +4,7 @@ import cn.seecoder.seecoderportalcommon.vo.CourseVO;
|
|
|
import cn.seecoder.seecoderportalserver.service.HttpService;
|
|
|
import cn.seecoder.seecoderportalserver.service.subsystem.SubsystemService;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.http.NameValuePair;
|
|
|
@@ -31,6 +32,7 @@ public class EaiService implements SubsystemService {
|
|
|
this.httpService = httpService;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
public JSONObject createCourse(CourseVO courseVO) {
|
|
|
// log.info("EAI新建课程:", courseVO);
|
|
|
@@ -39,8 +41,8 @@ public class EaiService implements SubsystemService {
|
|
|
String token = httpService.getToken();
|
|
|
JSONObject requestBody = new JSONObject();
|
|
|
|
|
|
- List<String> teacherNames = new ArrayList<>();
|
|
|
- teacherNames.add(courseVO.getTeacher().getName());
|
|
|
+ List<Long> teacherIds = new ArrayList<>();
|
|
|
+
|
|
|
|
|
|
List<String> courseImages = new ArrayList<>();
|
|
|
courseImages.add(courseVO.getImageUrl());
|
|
|
@@ -53,6 +55,9 @@ public class EaiService implements SubsystemService {
|
|
|
requestBody.put("endTime", Date.from(courseVO.getEndTime().toInstant()));
|
|
|
requestBody.put("description", courseVO.getDescription());
|
|
|
requestBody.put("enrollCode", courseVO.getInvitationCode());
|
|
|
+ requestBody.put("courseImages",courseImages);
|
|
|
+ requestBody.put("teacherIds", teacherIds);
|
|
|
+
|
|
|
String result = null;
|
|
|
try {
|
|
|
result = httpService.sendPost(uri, requestBody, null, token);
|
|
|
@@ -63,6 +68,7 @@ public class EaiService implements SubsystemService {
|
|
|
}
|
|
|
return JSON.parseObject(result);
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
public JSONObject updateCourse(CourseVO courseVO, Long userId){
|
|
|
String uri = eaiHost + "/api/course/portal";
|
|
|
@@ -71,9 +77,8 @@ public class EaiService implements SubsystemService {
|
|
|
String token = httpService.getToken();
|
|
|
|
|
|
// log.info("EAI修改课程信息:{}", courseVO.toString());
|
|
|
- System.out.println("EAI修改课程信息:" + courseVO.toString());
|
|
|
+ System.out.println("EAI修改课程信息:" + requestBody);
|
|
|
params.add(new BasicNameValuePair("courseId", String.valueOf(courseVO.getEaiId())));
|
|
|
-
|
|
|
try{
|
|
|
String result = httpService.sendPut(uri, requestBody, params, token);
|
|
|
return JSON.parseObject(result);
|
|
|
@@ -172,11 +177,44 @@ public class EaiService implements SubsystemService {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
public JSONObject findRecommendExamsByCourseId(int courseId){return null;}
|
|
|
|
|
|
- public JSONObject findTeacherExamsByCourseId(int courseId){return null;};
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public JSONObject findTeacherExamsByCourseId(int courseId){
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ result.put("array", this.getExamsByCourseId(courseId));
|
|
|
+ return result;
|
|
|
+ };
|
|
|
+
|
|
|
+ private JSONArray getExamsByCourseId(int courseId) {
|
|
|
+ String uri = eaiHost+"/api/assignment/query";
|
|
|
+ String token = httpService.getToken();
|
|
|
+ List<NameValuePair> params = new ArrayList<>();
|
|
|
+ params.add(new BasicNameValuePair("page", String.valueOf(1)));
|
|
|
+ params.add(new BasicNameValuePair("limit", String.valueOf(1000)));
|
|
|
+ JSONObject requestBody = new JSONObject();
|
|
|
+ requestBody.put("courseId", courseId);
|
|
|
+ JSONArray result = new JSONArray();
|
|
|
+ try {
|
|
|
+ String response = httpService.sendPost(
|
|
|
+ uri,
|
|
|
+ requestBody,
|
|
|
+ params, // URL 参数(分页)
|
|
|
+ token // 认证 Token
|
|
|
+ );
|
|
|
+ System.out.println(response); //{"code":200,"msg":"Success","data":{"records":[],"total":0,"size":10,"current":1,"pages":0}}
|
|
|
+
|
|
|
+ JSONArray exams = JSONObject.parseObject(response).getJSONObject("data").getJSONArray("records");
|
|
|
+ for (int i = 0; i < exams.size(); i++) {
|
|
|
+ result.add(exams.get(i));
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
|
|
|
public JSONObject findStudentExamsByCourseId(int courseId){return null;};
|
|
|
|