Răsfoiți Sursa

考生中增加学生id

ting.yin 8 ani în urmă
părinte
comite
2c702700e6

+ 5 - 5
exam-work-api/src/main/java/cn/com/qmth/examcloud/service/examwork/api/ExamStudentApi.java

@@ -52,14 +52,14 @@ public class ExamStudentApi {
 
     @ApiOperation(value="查询考试学生带条件和分页",notes = "带条件带分页")
     @GetMapping("/all/{curPage}/{pageSize}")
-    public ResponseEntity getAllExamStudent(@ModelAttribute ExamStudentDTO examCriteria, @PathVariable Integer curPage, @PathVariable Integer pageSize){
-        return new ResponseEntity(examStudentService.getAllExamStudent(examCriteria,new PageRequest(curPage - 1,pageSize)),HttpStatus.OK);
+    public ResponseEntity getAllExamStudent(@ModelAttribute ExamStudentDTO examStudent, @PathVariable Integer curPage, @PathVariable Integer pageSize){
+        return new ResponseEntity(examStudentService.getAllExamStudent(examStudent,new PageRequest(curPage - 1,pageSize)),HttpStatus.OK);
     }
 
     @ApiOperation(value="查询所有考试学生带条件",notes = "带条件不分页")
-    @GetMapping("/exam_student/all")
-    public ResponseEntity getAllExamStudent(@ModelAttribute ExamStudentDTO examCriteria){
-        return new ResponseEntity(examStudentService.getAllExamStudent(examCriteria), HttpStatus.OK);
+    @GetMapping("/all")
+    public ResponseEntity getAllExamStudent(@ModelAttribute ExamStudentDTO examStudent){
+        return new ResponseEntity(examStudentService.getAllExamStudent(examStudent), HttpStatus.OK);
     }
 
     @ApiOperation(value="按ID查询考试学生",notes = "ID查询")

+ 9 - 3
exam-work-api/src/main/java/cn/com/qmth/examcloud/service/examwork/service/ExamStudentService.java

@@ -163,7 +163,6 @@ public class ExamStudentService {
 	
 
 	private void saveExamStudentAndUser(List<ExamStudent> examStudents) {
-		examStudentRepo.save(examStudents);
 		for (ExamStudent examStudent : examStudents) {
 			Student student = new Student();
 			student.setIdentityNumber(examStudent.getIdentityNumber());
@@ -173,7 +172,9 @@ public class ExamStudentService {
 			user.setOrgId(examStudent.getOrgId());
 			user.setRootOrgId(examStudent.getRootOrgId());
 			student.setUser(user);
-			studentService.addStudent(student);
+			student = studentService.addStudent(student);
+			examStudent.setStudentId(student.getId());
+			examStudentRepo.save(examStudent);
 		}
 		examStudents.removeAll(examStudents);
 	}
@@ -242,7 +243,9 @@ public class ExamStudentService {
 	private Specification<ExamStudent> getSpecification(ExamStudentDTO examCriteria) {
 		Specification<ExamStudent> specification = (root, query, cb) -> {
 		    List<Predicate> predicates = new ArrayList<>();
-		    predicates.add(cb.equal(root.get("rootOrgId"),examCriteria.getRootOrgId()));
+		    if(null!=examCriteria.getRootOrgId()){
+		    	predicates.add(cb.equal(root.get("rootOrgId"),examCriteria.getRootOrgId()));
+		    }
 		    if(null!=examCriteria.getOrgId()){
 		    	predicates.add(cb.equal(root.get("orgId"),examCriteria.getOrgId()));
 		    }
@@ -258,6 +261,9 @@ public class ExamStudentService {
 		    if(null!=examCriteria.getFinished()){
 		    	predicates.add(cb.equal(root.get("finished"),examCriteria.getFinished()));
 		    }
+		    if(null!=examCriteria.getStudentId()){
+		    	predicates.add(cb.equal(root.get("studentId"),examCriteria.getStudentId()));
+		    }
 		    return cb.and(predicates.toArray(new Predicate[predicates.size()]));
 		};
 		return specification;

+ 10 - 0
exam-work-domain/src/main/java/cn/com/qmth/examcloud/service/examwork/dto/ExamStudentDTO.java

@@ -66,6 +66,8 @@ public class ExamStudentDTO {
 
 	private String remark;
 	
+	private Long studentId;
+	
 	/**
 	 * 是否缺考 
 	 */
@@ -231,6 +233,14 @@ public class ExamStudentDTO {
 		this.finished = finished;
 	}
 
+	public Long getStudentId() {
+		return studentId;
+	}
+
+	public void setStudentId(Long studentId) {
+		this.studentId = studentId;
+	}
+
 	public ExamStudentDTO() {
 	}
 }

+ 13 - 0
exam-work-domain/src/main/java/cn/com/qmth/examcloud/service/examwork/entity/ExamStudent.java

@@ -82,6 +82,11 @@ public class ExamStudent implements Serializable {
 	 * 是否缺考 
 	 */
 	private Boolean finished;
+	
+	/**
+	 * 学生用户id
+	 */
+    private Long studentId;
 
 	public static long getSerialVersionUID() {
 		return serialVersionUID;
@@ -251,6 +256,14 @@ public class ExamStudent implements Serializable {
 		this.finished = finished;
 	}
 
+	public Long getStudentId() {
+		return studentId;
+	}
+
+	public void setStudentId(Long studentId) {
+		this.studentId = studentId;
+	}
+
 	public ExamStudent() {
 	}
 }