Ver Fonte

修改按考试查询课程

宋悦 há 8 anos atrás
pai
commit
552d0a1576

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

@@ -11,6 +11,8 @@ import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
+import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * Created by yuanpan on 2017/4/12.
@@ -51,4 +53,22 @@ public class ExamCourseApi {
 
     }
 
+    @GetMapping("/marking")
+    public List<ExamCourseDTO> query(@RequestParam(value="exam_id",required = true) Long examId) {
+
+        List<ExamStudent> examStudents = examStudentRepo.findDistinctCourseCode(examId);
+
+        List<ExamCourseDTO> examCourseDTOs = examStudents.stream().map(examStudent -> {
+            ExamCourseDTO examCourseDTO = new ExamCourseDTO();
+            examCourseDTO.setExamId(examId);
+            examCourseDTO.setExamName(examStudent.getExam().getName());
+            examCourseDTO.setExamType(examStudent.getExam().getExamType());
+            examCourseDTO.setCourseName(examStudent.getCourseName());
+            examCourseDTO.setCourseCode(examStudent.getCourseCode());
+            return examCourseDTO;
+        }).collect(Collectors.toList());
+        return examCourseDTOs;
+
+    }
+
 }

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

@@ -16,6 +16,9 @@ public interface ExamStudentRepo extends JpaRepository<ExamStudent, Long>, Query
 
     List<ExamStudent> findByExamId(Long examId);
 
+    @Query("select s from ExamStudent s where s.exam.id=?1 group by s.courseCode")
+    List<ExamStudent> findDistinctCourseCode(Long examId);
+
     @Query("select s from ExamStudent s where s.exam.id=?1 group by s.courseCode")
     Page<ExamStudent> findDistinctCourseCode(Long examId, Pageable pageable);