|
@@ -36,11 +36,14 @@ import cn.com.qmth.examcloud.commons.base.util.ErrorMsg;
|
|
|
import cn.com.qmth.examcloud.commons.web.security.entity.AccessUser;
|
|
|
import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
|
import cn.com.qmth.examcloud.service.examwork.dao.ExamRepo;
|
|
|
-import cn.com.qmth.examcloud.service.examwork.dao.ExamSetting4CourseRepo;
|
|
|
+import cn.com.qmth.examcloud.service.examwork.api.bean.CourseGroupBean;
|
|
|
+import cn.com.qmth.examcloud.service.examwork.dao.CourseGroupRelationRepo;
|
|
|
+import cn.com.qmth.examcloud.service.examwork.dao.CourseGroupRepo;
|
|
|
import cn.com.qmth.examcloud.service.examwork.dao.ExamSetting4OrgRepo;
|
|
|
import cn.com.qmth.examcloud.service.examwork.dao.ExamStudentRepo;
|
|
|
import cn.com.qmth.examcloud.service.examwork.entity.Exam;
|
|
|
-import cn.com.qmth.examcloud.service.examwork.entity.ExamSetting4Course;
|
|
|
+import cn.com.qmth.examcloud.service.examwork.entity.CourseGroup;
|
|
|
+import cn.com.qmth.examcloud.service.examwork.entity.CourseGroupRelation;
|
|
|
import cn.com.qmth.examcloud.service.examwork.entity.ExamSetting4Org;
|
|
|
import cn.com.qmth.examcloud.service.examwork.entity.ExamStudent;
|
|
|
import cn.com.qmth.examcloud.service.examwork.enums.ExamType;
|
|
@@ -68,10 +71,13 @@ public class ExamApi extends ControllerSupport {
|
|
|
ExamStudentService examStudentService;
|
|
|
|
|
|
@Autowired
|
|
|
- ExamSetting4CourseRepo examSetting4CourseRepo;
|
|
|
+ CourseGroupRepo courseGroupRepo;
|
|
|
|
|
|
@Autowired
|
|
|
ExamSetting4OrgRepo examSetting4OrgRepo;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ CourseGroupRelationRepo courseGroupRelationRepo;
|
|
|
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
@@ -268,89 +274,124 @@ public class ExamApi extends ControllerSupport {
|
|
|
return new ResponseEntity(HttpStatus.OK);
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "查询特殊考试设置", notes = "查询特殊考试设置")
|
|
|
- @GetMapping("/exam/querySpecificExamList/{examId}/{curPage}/{pageSize}")
|
|
|
- public ResponseEntity<?> querySpecificExamList(@PathVariable Long examId,
|
|
|
+ @ApiOperation(value = "查询课程组集合", notes = "")
|
|
|
+ @GetMapping("/exam/queryCourseGroupList/{examId}/{curPage}/{pageSize}")
|
|
|
+ public List<CourseGroupBean> queryCourseGroupList(@PathVariable Long examId,
|
|
|
@PathVariable Integer curPage, @PathVariable Integer pageSize) {
|
|
|
|
|
|
- List<ExamSetting4Course> groupList = examSetting4CourseRepo.findByExamId(examId,
|
|
|
- (curPage - 1) * pageSize, pageSize);
|
|
|
+ Pageable pageable = new PageRequest(curPage-1, pageSize, Sort.Direction.DESC, "updateTime");
|
|
|
+ List<CourseGroup> groupList = courseGroupRepo.findAllByExamId(examId, pageable);
|
|
|
+
|
|
|
+ List<CourseGroupBean> ret = Lists.newArrayList();
|
|
|
+
|
|
|
+ for (CourseGroup curCourseGroup : groupList) {
|
|
|
+ CourseGroupBean bean = new CourseGroupBean();
|
|
|
+ bean.setBeginTime(curCourseGroup.getBeginTime());
|
|
|
+ bean.setCreationTime(curCourseGroup.getCreationTime());
|
|
|
+ bean.setDescription(curCourseGroup.getDescription());
|
|
|
+ bean.setEndTime(curCourseGroup.getEndTime());
|
|
|
+ bean.setExamId(curCourseGroup.getExamId());
|
|
|
+ bean.setId(curCourseGroup.getId());
|
|
|
+ bean.setName(curCourseGroup.getName());
|
|
|
+ bean.setUpdateTime(curCourseGroup.getUpdateTime());
|
|
|
|
|
|
- for (ExamSetting4Course specificExam : groupList) {
|
|
|
List<Long> courseIdList = Lists.newArrayList();
|
|
|
- specificExam.setCourseIdList(courseIdList);
|
|
|
-
|
|
|
- List<Map<String, Object>> queryList = jdbcTemplate.queryForList(
|
|
|
- "select t.course_id from ecs_e_exam_course_relation t where t.specific_exam_id=?",
|
|
|
- specificExam.getId());
|
|
|
- if (CollectionUtils.isNotEmpty(queryList)) {
|
|
|
- for (Map<String, Object> map : queryList) {
|
|
|
- Long courseId = Long.valueOf(map.get("COURSE_ID").toString());
|
|
|
- courseIdList.add(courseId);
|
|
|
- }
|
|
|
+ bean.setCourseIdList(courseIdList);
|
|
|
+
|
|
|
+ List<CourseGroupRelation> relationList = courseGroupRelationRepo
|
|
|
+ .findAllByGroupId(bean.getId());
|
|
|
+
|
|
|
+ for (CourseGroupRelation cur : relationList) {
|
|
|
+ courseIdList.add(cur.getCourseId());
|
|
|
}
|
|
|
+
|
|
|
+ ret.add(bean);
|
|
|
}
|
|
|
|
|
|
- return new ResponseEntity<List<ExamSetting4Course>>(groupList, HttpStatus.OK);
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "通过课程ID查询特殊考试设置", notes = "通过课程ID查询特殊考试设置")
|
|
|
- @GetMapping("/exam/querySpecificExamByCourseId/{courseId}")
|
|
|
- public ResponseEntity<?> querySpecificExamByCourseId(@PathVariable Long courseId) {
|
|
|
- List<ExamSetting4Course> groupList = examSetting4CourseRepo
|
|
|
- .queryCourseGroupsByCourseId(courseId);
|
|
|
+ @ApiOperation(value = "通过课程ID查询课程组集合", notes = "")
|
|
|
+ @GetMapping("/exam/queryCourseGroupList/{examId}/{courseId}")
|
|
|
+ public List<CourseGroupBean> queryCourseGroupList(@PathVariable Long examId,
|
|
|
+ @PathVariable Long courseId) {
|
|
|
+
|
|
|
+ List<CourseGroupRelation> relationList = courseGroupRelationRepo
|
|
|
+ .findAllByCourseIdAndExamId(courseId, examId);
|
|
|
+
|
|
|
+ List<Long> groupIdList = Lists.newArrayList();
|
|
|
+ for (CourseGroupRelation cur : relationList) {
|
|
|
+ Long groupId = cur.getGroupId();
|
|
|
+ groupIdList.add(groupId);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<CourseGroup> groupList = courseGroupRepo
|
|
|
+ .findAllByIdInOrderByUpdateTimeDesc(groupIdList);
|
|
|
+
|
|
|
+ List<CourseGroupBean> ret = Lists.newArrayList();
|
|
|
+
|
|
|
+ for (CourseGroup curCourseGroup : groupList) {
|
|
|
+ CourseGroupBean bean = new CourseGroupBean();
|
|
|
+ bean.setBeginTime(curCourseGroup.getBeginTime());
|
|
|
+ bean.setCreationTime(curCourseGroup.getCreationTime());
|
|
|
+ bean.setDescription(curCourseGroup.getDescription());
|
|
|
+ bean.setEndTime(curCourseGroup.getEndTime());
|
|
|
+ bean.setExamId(curCourseGroup.getExamId());
|
|
|
+ bean.setId(curCourseGroup.getId());
|
|
|
+ bean.setName(curCourseGroup.getName());
|
|
|
+ bean.setUpdateTime(curCourseGroup.getUpdateTime());
|
|
|
|
|
|
- for (ExamSetting4Course specificExam : groupList) {
|
|
|
List<Long> courseIdList = Lists.newArrayList();
|
|
|
- specificExam.setCourseIdList(courseIdList);
|
|
|
-
|
|
|
- List<Map<String, Object>> queryList = jdbcTemplate.queryForList(
|
|
|
- "select t.course_id from ecs_e_exam_course_relation t where t.specific_exam_id=?",
|
|
|
- specificExam.getId());
|
|
|
- if (CollectionUtils.isNotEmpty(queryList)) {
|
|
|
- for (Map<String, Object> map : queryList) {
|
|
|
- Long curCourseId = Long.valueOf(map.get("COURSE_ID").toString());
|
|
|
- courseIdList.add(curCourseId);
|
|
|
- }
|
|
|
+ bean.setCourseIdList(courseIdList);
|
|
|
+
|
|
|
+ List<CourseGroupRelation> curRelationList = courseGroupRelationRepo
|
|
|
+ .findAllByGroupId(bean.getId());
|
|
|
+
|
|
|
+ for (CourseGroupRelation cur : curRelationList) {
|
|
|
+ courseIdList.add(cur.getCourseId());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return new ResponseEntity<Object>(groupList, HttpStatus.OK);
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "更新特殊考试设置", notes = "更新特殊考试设置")
|
|
|
- @PutMapping("/exam/specificExam")
|
|
|
- public ResponseEntity<?> updateSpecificExam(@RequestBody ExamSetting4Course specificExam,
|
|
|
+ @ApiOperation(value = "更新课程组", notes = "")
|
|
|
+ @PutMapping("/exam/courseGroup")
|
|
|
+ public void updateCourseGroup(@RequestBody CourseGroupBean courseGroupBean,
|
|
|
HttpServletRequest request) {
|
|
|
|
|
|
- examSetting4CourseRepo.save(specificExam);
|
|
|
- Long specificExamId = specificExam.getId();
|
|
|
- Long examId = specificExam.getExamId();
|
|
|
-
|
|
|
- List<Long> courseIdList = specificExam.getCourseIdList();
|
|
|
- jdbcTemplate.update("delete from ecs_e_exam_course_relation where specific_exam_id=?",
|
|
|
- specificExamId);
|
|
|
-
|
|
|
- if (CollectionUtils.isNotEmpty(courseIdList)) {
|
|
|
- for (Long courseId : courseIdList) {
|
|
|
- jdbcTemplate.update(
|
|
|
- "delete from ecs_e_exam_course_relation where exam_id=? and course_id=?",
|
|
|
- specificExamId, courseId);
|
|
|
- jdbcTemplate.update(
|
|
|
- "insert into ecs_e_exam_course_relation(specific_exam_id,course_id,exam_id) values(?,?,?)",
|
|
|
- specificExamId, courseId, examId);
|
|
|
- }
|
|
|
+ CourseGroup courseGroup = new CourseGroup();
|
|
|
+ courseGroup.setBeginTime(courseGroupBean.getBeginTime());
|
|
|
+ courseGroup.setCreationTime(courseGroupBean.getCreationTime());
|
|
|
+ courseGroup.setDescription(courseGroupBean.getDescription());
|
|
|
+ courseGroup.setEndTime(courseGroupBean.getEndTime());
|
|
|
+ courseGroup.setExamId(courseGroupBean.getExamId());
|
|
|
+ courseGroup.setId(courseGroupBean.getId());
|
|
|
+ courseGroup.setName(courseGroupBean.getName());
|
|
|
+ courseGroup.setUpdateTime(courseGroupBean.getUpdateTime());
|
|
|
+
|
|
|
+ courseGroupRepo.save(courseGroup);
|
|
|
+ List<Long> courseIdList = courseGroupBean.getCourseIdList();
|
|
|
+
|
|
|
+ List<CourseGroupRelation> relationList = Lists.newArrayList();
|
|
|
+
|
|
|
+ courseGroupRelationRepo.deleteByGroupId(courseGroup.getId());
|
|
|
+
|
|
|
+ for (Long cur : courseIdList) {
|
|
|
+ CourseGroupRelation relation = new CourseGroupRelation();
|
|
|
+ relation.setCourseId(cur);
|
|
|
+ relation.setExamId(courseGroupBean.getExamId());
|
|
|
+ relation.setGroupId(courseGroup.getId());
|
|
|
+ relationList.add(relation);
|
|
|
}
|
|
|
-
|
|
|
- return new ResponseEntity<Object>(HttpStatus.OK);
|
|
|
+ courseGroupRelationRepo.save(relationList);
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "删除特殊考试设置", notes = "删除特殊考试设置")
|
|
|
- @DeleteMapping("/exam/specificExam/{id}")
|
|
|
- public ResponseEntity<?> deleteSpecificExam(@PathVariable Long id, HttpServletRequest request) {
|
|
|
- examSetting4CourseRepo.delete(id);
|
|
|
- jdbcTemplate.update("delete from ecs_e_exam_course_relation where group_id=?", id);
|
|
|
- return new ResponseEntity<Object>(HttpStatus.OK);
|
|
|
+ @ApiOperation(value = "删除课程组", notes = "删除特殊考试设置")
|
|
|
+ @DeleteMapping("/exam/courseGroup/{id}")
|
|
|
+ public void deleteSpecificExam(@PathVariable Long id, HttpServletRequest request) {
|
|
|
+ courseGroupRepo.delete(id);
|
|
|
+ courseGroupRelationRepo.deleteByGroupId(id);
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "查询考试相关的学习中心设置", notes = "查询考试相关的学习中心设置")
|