|
@@ -13,6 +13,8 @@ import java.util.List;
|
|
|
import java.util.zip.ZipEntry;
|
|
|
import java.util.zip.ZipInputStream;
|
|
|
|
|
|
+import javax.persistence.criteria.Predicate;
|
|
|
+
|
|
|
import org.json.JSONArray;
|
|
|
import org.json.JSONObject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -21,6 +23,7 @@ import org.springframework.data.domain.Example;
|
|
|
import org.springframework.data.domain.ExampleMatcher;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
+import org.springframework.data.jpa.domain.Specification;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
@@ -67,10 +70,17 @@ public class ExamStudentService {
|
|
|
* @return
|
|
|
*/
|
|
|
public Page<ExamStudent> getAllExamStudent(ExamStudent examCriteria, Pageable pageable){
|
|
|
- ExampleMatcher exampleMatcher = ExampleMatcher.matching()
|
|
|
- .withMatcher("name",startsWith());
|
|
|
- Example<ExamStudent> examExamStudentple = Example.of(examCriteria, exampleMatcher);
|
|
|
- return examStudentRepo.findAll(examExamStudentple,pageable);
|
|
|
+// ExampleMatcher exampleMatcher = ExampleMatcher.matching()
|
|
|
+// .withMatcher("name",startsWith());
|
|
|
+// Example<ExamStudent> examExamStudentple = Example.of(examCriteria, exampleMatcher);
|
|
|
+// return examStudentRepo.findAll(examExamStudentple,pageable);
|
|
|
+ Specification<ExamStudent> specification = (root, query, cb) -> {
|
|
|
+ List<Predicate> predicates = new ArrayList<>();
|
|
|
+ predicates.add(cb.like(root.get("name"),examCriteria.getName()));
|
|
|
+ predicates.add(cb.like(root.get("studentCode"),examCriteria.getStudentCode()));
|
|
|
+ return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
+ };
|
|
|
+ return examStudentRepo.findAll(specification,pageable);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -265,7 +275,7 @@ public class ExamStudentService {
|
|
|
JSONArray faceArray = face.getJSONArray("face");
|
|
|
if (faceArray.length() > 0) {
|
|
|
//人脸识别成功
|
|
|
-// studentService.updatePhoto(identityNumber);
|
|
|
+ studentService.updatePhoto(identityNumber);
|
|
|
} else {
|
|
|
error = new ErrorMsg(identityNumber + JPG + "不能被识别人脸,请换一张清晰的照片重新上传!");
|
|
|
}
|