|
@@ -0,0 +1,75 @@
|
|
|
|
+package cn.com.qmth.examcloud.core.oe.admin.api.provider;
|
|
|
|
+
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.CourseCloudService;
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.bean.CourseBean;
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.request.GetCoursesByIdListReq;
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.response.GetCoursesByIdListResp;
|
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.api.ExamCourseCloudService;
|
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.api.bean.ExamCourseBean;
|
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.api.request.GetExamCourseReq;
|
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.api.response.GetExamCourseResp;
|
|
|
|
+import cn.com.qmth.examcloud.web.support.ControllerSupport;
|
|
|
|
+import io.swagger.annotations.Api;
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
+
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
+@Api(tags = "获取考试相关课程接口")
|
|
|
|
+@RestController
|
|
|
|
+@RequestMapping("${$rmp.cloud.oe}/exam/course")
|
|
|
|
+public class ExamCourseCloudServiceProvider extends ControllerSupport implements ExamCourseCloudService {
|
|
|
|
+
|
|
|
|
+ private static final long serialVersionUID = 4538819077863159166L;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private CourseCloudService courseCloudService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private JdbcTemplate jdbcTemplate;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ @ApiOperation(value = "获取考试相关的课程列表")
|
|
|
|
+ @PostMapping("/getExamCourses")
|
|
|
|
+ public GetExamCourseResp getExamCourses(@RequestBody GetExamCourseReq req) {
|
|
|
|
+ List<Long> courseIds = this.queryExamCourseIds(req.getExamId());
|
|
|
|
+
|
|
|
|
+ GetExamCourseResp resp = new GetExamCourseResp();
|
|
|
|
+ List<ExamCourseBean> courses = new ArrayList<>();
|
|
|
|
+ resp.setList(courses);
|
|
|
|
+ if (CollectionUtils.isEmpty(courseIds)) {
|
|
|
|
+ return resp;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ GetCoursesByIdListReq courseReq = new GetCoursesByIdListReq();
|
|
|
|
+ courseReq.setCourseIdList(courseIds);
|
|
|
|
+ GetCoursesByIdListResp courseResp = courseCloudService.getCoursesByIdList(courseReq);
|
|
|
|
+
|
|
|
|
+ for (CourseBean bean : courseResp.getCourseList()) {
|
|
|
|
+ ExamCourseBean course = new ExamCourseBean();
|
|
|
|
+ course.setId(bean.getId());
|
|
|
|
+ course.setCode(bean.getCode());
|
|
|
|
+ course.setName(bean.getName());
|
|
|
|
+ courses.add(course);
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return resp;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private List<Long> queryExamCourseIds(Long examId) {
|
|
|
|
+ final String querySql = String.format("select distinct course_id from ec_oe_exam_student where exam_id = %s and enable = 1", examId);
|
|
|
|
+ return jdbcTemplate.queryForList(querySql, Long.class);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|