|
@@ -12,68 +12,73 @@ import org.springframework.data.repository.query.Param;
|
|
|
import org.springframework.data.repository.query.QueryByExampleExecutor;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.core.examwork.dao.entity.Exam;
|
|
|
import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamStudent;
|
|
|
|
|
|
-public interface ExamStudentRepo extends JpaRepository<ExamStudent, Long>, QueryByExampleExecutor<ExamStudent>, JpaSpecificationExecutor<ExamStudent> {
|
|
|
- Page<ExamStudent> findByExamId(Long examId, Pageable pageable);
|
|
|
+public interface ExamStudentRepo
|
|
|
+ extends
|
|
|
+ JpaRepository<ExamStudent, Long>,
|
|
|
+ QueryByExampleExecutor<ExamStudent>,
|
|
|
+ JpaSpecificationExecutor<ExamStudent> {
|
|
|
+ Page<ExamStudent> findByExamId(Long examId, Pageable pageable);
|
|
|
|
|
|
- List<ExamStudent> findByExamId(Long examId);
|
|
|
+ List<ExamStudent> findByExamId(Long examId);
|
|
|
|
|
|
- @Query("select s from ExamStudent s where s.exam.id=?1 group by s.courseCode order by s.courseCode")
|
|
|
- List<ExamStudent> findDistinctCourseCode(Long examId);
|
|
|
+ @Query("select s from ExamStudent s where s.exam.id=?1 group by s.courseCode order by s.courseCode")
|
|
|
+ List<ExamStudent> findDistinctCourseCode(Long examId);
|
|
|
|
|
|
- @Query("select s from ExamStudent s where s.exam.id=?1 and s.courseCode = ?2 group by s.courseCode order by s.courseCode")
|
|
|
- List<ExamStudent> findDistinctCourseCode(Long examId, String courseCode);
|
|
|
+ @Query("select s from ExamStudent s where s.exam.id=?1 and s.courseCode = ?2 group by s.courseCode order by s.courseCode")
|
|
|
+ List<ExamStudent> findDistinctCourseCode(Long examId, String courseCode);
|
|
|
|
|
|
- @Query("select s from ExamStudent s where s.exam.id=?1 group by s.courseCode order by s.courseCode")
|
|
|
- Page<ExamStudent> findDistinctCourseCode(Long examId, Pageable pageable);
|
|
|
+ @Query("select s from ExamStudent s where s.exam.id=?1 group by s.courseCode order by s.courseCode")
|
|
|
+ Page<ExamStudent> findDistinctCourseCode(Long examId, Pageable pageable);
|
|
|
|
|
|
- @Query("select s from ExamStudent s where s.exam.id=?1 and s.courseCode = ?2 group by s.courseCode order by s.courseCode")
|
|
|
- Page<ExamStudent> findDistinctCourseCode(Long examId, String courseCode, Pageable pageable);
|
|
|
+ @Query("select s from ExamStudent s where s.exam.id=?1 and s.courseCode = ?2 group by s.courseCode order by s.courseCode")
|
|
|
+ Page<ExamStudent> findDistinctCourseCode(Long examId, String courseCode, Pageable pageable);
|
|
|
|
|
|
- List<ExamStudent> findByIdIn(List<Long> ids);
|
|
|
+ List<ExamStudent> findByIdIn(List<Long> ids);
|
|
|
|
|
|
- @Query("select s from ExamStudent s where s.exam.id=?1 and s.courseCode =?2 group by s.paperType")
|
|
|
- List<ExamStudent> findDistinctPaperType(Long examId, String courseCode);
|
|
|
+ @Query("select s from ExamStudent s where s.exam.id=?1 and s.courseCode =?2 group by s.paperType")
|
|
|
+ List<ExamStudent> findDistinctPaperType(Long examId, String courseCode);
|
|
|
|
|
|
- @Query("select s from ExamStudent s where s.exam.id = ?1 and s.courseCode = ?2 and (s.studentCode = ?3 or s.identityNumber = ?3)")
|
|
|
- ExamStudent findFirstByExamId(Long examId, String courseCode, String stuNumber);
|
|
|
+ @Query("select s from ExamStudent s where s.exam.id = ?1 and s.courseCode = ?2 and (s.studentCode = ?3 or s.identityNumber = ?3)")
|
|
|
+ ExamStudent findFirstByExamId(Long examId, String courseCode, String stuNumber);
|
|
|
|
|
|
- @Query("select count(s) from ExamStudent s where s.exam.id = ?1 and s.rootOrgId=?2 and s.identityNumber=?3 and s.courseCode=?4 and s.id <> ?5")
|
|
|
- int checkExamStuById(Long examId, Long rootOrgId, String identityNumber, String courseCode, Long id);
|
|
|
+ @Query("select count(s) from ExamStudent s where s.exam.id = ?1 and s.rootOrgId=?2 and s.identityNumber=?3 and s.courseCode=?4 and s.id <> ?5")
|
|
|
+ int checkExamStuById(Long examId, Long rootOrgId, String identityNumber, String courseCode,
|
|
|
+ Long id);
|
|
|
|
|
|
- @Query("select count(s) from ExamStudent s where s.exam.id = ?1 and s.rootOrgId=?2 and s.identityNumber=?3 and s.courseCode=?4")
|
|
|
- int checkExamStu(Long examId, Long rootOrgId, String identityNumber, String courseCode);
|
|
|
+ @Query("select count(s) from ExamStudent s where s.exam.id = ?1 and s.rootOrgId=?2 and s.identityNumber=?3 and s.courseCode=?4")
|
|
|
+ int checkExamStu(Long examId, Long rootOrgId, String identityNumber, String courseCode);
|
|
|
|
|
|
- @Transactional
|
|
|
- @Modifying
|
|
|
- @Query("update ExamStudent s set s.name = ?2,s.specialtyName = ?3,s.examSite = ?4 where s.identityNumber = ?1")
|
|
|
- void updateById(String identityNumber, String name, String specialtyName, String examSite);
|
|
|
+ @Transactional
|
|
|
+ @Modifying
|
|
|
+ @Query("update ExamStudent s set s.name = ?2,s.specialtyName = ?3,s.examSite = ?4 where s.identityNumber = ?1")
|
|
|
+ void updateById(String identityNumber, String name, String specialtyName, String examSite);
|
|
|
|
|
|
- @Query("select s from ExamStudent s where s.rootOrgId=?1 and s.courseCode=?2")
|
|
|
- List<ExamStudent> findByCourseCode(Long rootOrgId, String courseCode);
|
|
|
+ @Query("select s from ExamStudent s where s.rootOrgId=?1 and s.courseCode=?2")
|
|
|
+ List<ExamStudent> findByCourseCode(Long rootOrgId, String courseCode);
|
|
|
|
|
|
- List<ExamStudent> findByOrgId(Long orgId);
|
|
|
+ List<ExamStudent> findByOrgId(Long orgId);
|
|
|
|
|
|
- @Transactional
|
|
|
- @Modifying
|
|
|
- @Query("delete from ExamStudent s where s.exam.id = ?1")
|
|
|
- void deleteByExamId(Long examId);
|
|
|
+ @Transactional
|
|
|
+ @Modifying
|
|
|
+ @Query("delete from ExamStudent s where s.exam.id = ?1")
|
|
|
+ void deleteByExamId(Long examId);
|
|
|
|
|
|
- int countByExamIdAndFinished(Long examId, Boolean finished);
|
|
|
+ int countByExamIdAndFinished(Long examId, Boolean finished);
|
|
|
|
|
|
- @Query(nativeQuery = true,value = "select org_id, org_name, finished, count(id) from ecs_exam_student where exam_id = :examId group by org_id, org_name, finished")
|
|
|
- List<Object[]> countByCampusAndFinished(@Param("examId") Long examId);
|
|
|
+ @Query(nativeQuery = true, value = "select org_id, org_name, finished, count(id) from ecs_exam_student where exam_id = :examId group by org_id, org_name, finished")
|
|
|
+ List<Object[]> countByCampusAndFinished(@Param("examId") Long examId);
|
|
|
|
|
|
+ @Transactional
|
|
|
+ @Modifying
|
|
|
+ @Query("update ExamStudent e set e.finished = ?2 where e.id = ?1")
|
|
|
+ void updateForFinished(Long id, Boolean finished);
|
|
|
|
|
|
- @Transactional
|
|
|
- @Modifying
|
|
|
- @Query("update ExamStudent e set e.finished = ?2 where e.id = ?1")
|
|
|
- void updateForFinished(Long id,Boolean finished);
|
|
|
-
|
|
|
- @Query(value = "SELECT * FROM ecs_exam_student t WHERE t.exam_id = ?1 order by id desc limit ?2,?3 ",nativeQuery = true)
|
|
|
- public List<ExamStudent> findByLimit(Long examId,Integer startLimit,Integer endLimit);
|
|
|
-
|
|
|
- @Query("select s from ExamStudent s where s.examId=?1 and s.studentId=?2 and s.courseCode=?3")
|
|
|
- List<ExamStudent> findByExamIdAndStudentIdAndCourseCode(Long examId,Long studentId, String courseCode);
|
|
|
+ @Query(value = "SELECT * FROM ecs_exam_student t WHERE t.exam_id = ?1 order by id desc limit ?2,?3 ", nativeQuery = true)
|
|
|
+ public List<ExamStudent> findByLimit(Long examId, Integer startLimit, Integer endLimit);
|
|
|
+
|
|
|
+ List<ExamStudent> findByExamAndStudentIdAndCourseCode(Exam exam, Long studentId,
|
|
|
+ String courseCode);
|
|
|
}
|