wangwei 7 jaren geleden
bovenliggende
commit
a338c11f23

+ 22 - 0
exam-work-api/src/main/java/cn/com/qmth/examcloud/service/examwork/api/ExamApi.java

@@ -245,6 +245,28 @@ public class ExamApi extends ControllerSupport {
 		return new ResponseEntity<List<CourseGroup>>(groupList, HttpStatus.OK);
 	}
 
+	@ApiOperation(value = "查询课程组", notes = "查询课程组")
+	@GetMapping("/exam/queryCourseGroupsByCourseId/{courseId}")
+	public ResponseEntity<?> queryCourseGroupsByCourseId(@PathVariable Long courseId) {
+		List<CourseGroup> groupList = courseGroupRepo.queryCourseGroupsByCourseId(courseId);
+
+		for (CourseGroup courseGroup : groupList) {
+			List<Long> courseIdList = Lists.newArrayList();
+			courseGroup.setCourseIdList(courseIdList);
+
+			List<Map<String, Object>> queryList = jdbcTemplate.queryForList(
+					"select t.course_id from ecs_exam_course_group_course t where t.group_id=?", courseGroup.getId());
+			if (CollectionUtils.isNotEmpty(queryList)) {
+				for (Map<String, Object> map : queryList) {
+					Long curCourseId = Long.valueOf(map.get("COURSE_ID").toString());
+					courseIdList.add(curCourseId);
+				}
+			}
+		}
+
+		return new ResponseEntity<Object>(HttpStatus.OK);
+	}
+
 	@ApiOperation(value = "添加课程组", notes = "添加课程组")
 	@PutMapping("/exam/courseGroup")
 	public ResponseEntity<?> addCourseGroup(@RequestBody CourseGroup courseGroup, HttpServletRequest request) {

+ 3 - 0
exam-work-domain/src/main/java/cn/com/qmth/examcloud/service/examwork/dao/CourseGroupRepo.java

@@ -15,4 +15,7 @@ public interface CourseGroupRepo extends JpaRepository<CourseGroup, Long>, Query
 	List<CourseGroup> findByExamId(@Param("examId") Long examId, @Param("curPage") Integer curPage,
 			@Param("pageSize") Integer pageSize);
 
+	@Query(value = "select x.* from ecs_exam_course_group x,ecs_exam_course_group_course  y where x.id=y.group_id and y.course_id=?1", nativeQuery = true)
+	List<CourseGroup> queryCourseGroupsByCourseId(@Param("courseId") Long courseId);
+
 }