|
|
@@ -0,0 +1,94 @@
|
|
|
+package cn.seecoder.seecoderportalserver.serviceImpl.subsystem;
|
|
|
+
|
|
|
+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.JSONObject;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author XiaoYu
|
|
|
+ * @date 2025/2/24 下午6:44
|
|
|
+ * @description: EaiService
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class EaiService implements SubsystemService {
|
|
|
+ private final HttpService httpService;
|
|
|
+ @Value("${eai.host}")
|
|
|
+ private String eaiHost;
|
|
|
+
|
|
|
+ public EaiService(HttpService httpService) {
|
|
|
+ this.httpService = httpService;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public JSONObject createCourse(CourseVO courseVO) {
|
|
|
+ String uri = eaiHost + "/api/course";
|
|
|
+ String token = httpService.getToken();
|
|
|
+ JSONObject requestBody = new JSONObject();
|
|
|
+
|
|
|
+ List<String> teacherNames = new ArrayList<>();
|
|
|
+ teacherNames.add(courseVO.getTeacher().getName());
|
|
|
+
|
|
|
+ List<String> courseImages = new ArrayList<>();
|
|
|
+ courseImages.add(courseVO.getImageUrl());
|
|
|
+
|
|
|
+ List<Long> teacherIds = new ArrayList<>();
|
|
|
+ teacherIds.add(courseVO.getId());
|
|
|
+
|
|
|
+ //对应eai中的CourseDT0
|
|
|
+ requestBody.put("courseName", courseVO.getName());
|
|
|
+ requestBody.put("teacherIds", teacherIds);
|
|
|
+ requestBody.put("targetGrade", courseVO.getSemester());
|
|
|
+ requestBody.put("startTime", Date.from(courseVO.getStartTime().toInstant()));
|
|
|
+ requestBody.put("endTime", Date.from(courseVO.getEndTime().toInstant()));
|
|
|
+ requestBody.put("description", courseVO.getDescription());
|
|
|
+
|
|
|
+ //对应eai中的CourseVO
|
|
|
+// requestBody.put("courseName", courseVO.getName());
|
|
|
+// requestBody.put("teacherIds", teacherIds);
|
|
|
+// requestBody.put("teacherNames", teacherNames);
|
|
|
+// requestBody.put("courseImages", courseImages);
|
|
|
+// requestBody.put("targetGrade", courseVO.getSemester());
|
|
|
+// //portal中的时间为OffsetDateTime,EAI中为Date,需要转换
|
|
|
+// requestBody.put("startTime", Date.from(courseVO.getStartTime().toInstant()));
|
|
|
+// requestBody.put("endTime", Date.from(courseVO.getEndTime().toInstant()));
|
|
|
+// requestBody.put("createTime", Date.from(courseVO.getCreatedTime().toInstant()));
|
|
|
+// requestBody.put("description", courseVO.getDescription());
|
|
|
+
|
|
|
+ String result = null;
|
|
|
+ try {
|
|
|
+ result = httpService.sendPost(uri, requestBody, null, token);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return JSON.parseObject(result);
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public void deleteCourse(CourseVO courseVO) {
|
|
|
+
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public JSONObject chooseCourse(String code) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public JSONObject findRecommendExamsByCourseId(int courseId){return null;}
|
|
|
+
|
|
|
+ public JSONObject findTeacherExamsByCourseId(int courseId){return null;};
|
|
|
+
|
|
|
+ public JSONObject findStudentExamsByCourseId(int courseId){return null;};
|
|
|
+
|
|
|
+ public JSONObject findTeacherExams(int page, int limit, int state){return null;};
|
|
|
+
|
|
|
+ public JSONObject findStudentExams(int page, int limit, int state){return null;};
|
|
|
+
|
|
|
+
|
|
|
+}
|