|
@@ -15,11 +15,16 @@ import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
+import javax.persistence.criteria.CriteriaBuilder;
|
|
|
+import javax.persistence.criteria.CriteriaQuery;
|
|
|
+import javax.persistence.criteria.Predicate;
|
|
|
+import javax.persistence.criteria.Root;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
+import org.springframework.data.jpa.domain.Specification;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
@@ -64,6 +69,22 @@ public class ExamStudentApi {
|
|
|
@Autowired
|
|
|
ExamRepo examRepo;
|
|
|
|
|
|
+ @GetMapping("/query")
|
|
|
+ public List<ExamStudent> find(@RequestParam(value = "student_id", required = false) Long studentId) {
|
|
|
+
|
|
|
+ return examStudentRepo.findAll((root, query, cb) -> {
|
|
|
+
|
|
|
+ List<Predicate> predicates = new ArrayList<Predicate>();
|
|
|
+
|
|
|
+ if (studentId != null) {
|
|
|
+ predicates.add(cb.equal(root.get("studentId"), studentId));
|
|
|
+ }
|
|
|
+
|
|
|
+ Predicate[] pre = new Predicate[predicates.size()];
|
|
|
+ return query.where(predicates.toArray(pre)).getRestriction();
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation(value = "查询考试学生带条件和分页", notes = "带条件带分页")
|
|
|
@GetMapping("/all/{curPage}/{pageSize}")
|
|
|
public ResponseEntity getAllExamStudent(HttpServletRequest request,
|
|
@@ -71,13 +92,13 @@ public class ExamStudentApi {
|
|
|
@PathVariable Integer curPage,
|
|
|
@PathVariable Integer pageSize) {
|
|
|
AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
|
|
|
- if(accessUser != null){
|
|
|
- if(accessUser.getRootOrgId().longValue() == accessUser.getOrgId().longValue()){
|
|
|
+ if (accessUser != null) {
|
|
|
+ if (accessUser.getRootOrgId().longValue() == accessUser.getOrgId().longValue()) {
|
|
|
examStudent.setRootOrgId(accessUser.getRootOrgId());
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
examStudent.setOrgId(accessUser.getOrgId());
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
return new ResponseEntity(HttpStatus.NOT_FOUND);
|
|
|
}
|
|
|
return new ResponseEntity(examStudentService.getAllExamStudent(examStudent,
|
|
@@ -89,10 +110,10 @@ public class ExamStudentApi {
|
|
|
public ResponseEntity getAllExamStudent(HttpServletRequest request,
|
|
|
@ModelAttribute ExamStudentDTO examStudent) {
|
|
|
AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
|
|
|
- if(accessUser != null){
|
|
|
- if(accessUser.getRootOrgId().longValue() == accessUser.getOrgId().longValue()){
|
|
|
+ if (accessUser != null) {
|
|
|
+ if (accessUser.getRootOrgId().longValue() == accessUser.getOrgId().longValue()) {
|
|
|
examStudent.setRootOrgId(accessUser.getRootOrgId());
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
examStudent.setOrgId(accessUser.getOrgId());
|
|
|
}
|
|
|
}
|
|
@@ -118,9 +139,9 @@ public class ExamStudentApi {
|
|
|
examStudent.setExam(exam);
|
|
|
ExamStudent saveExamStu = examStudentService.saveExamStudent(examStudent);
|
|
|
return new ResponseEntity(saveExamStu, HttpStatus.OK);
|
|
|
- } catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- return new ResponseEntity(new ErrorMsg(e.getMessage()),HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ return new ResponseEntity(new ErrorMsg(e.getMessage()), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -157,7 +178,7 @@ public class ExamStudentApi {
|
|
|
return new ResponseEntity(HttpStatus.OK);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- return new ResponseEntity(new ErrorMsg(e.getMessage()),HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ return new ResponseEntity(new ErrorMsg(e.getMessage()), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -186,10 +207,10 @@ public class ExamStudentApi {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value="下载导入模板",notes = "下载导入模板")
|
|
|
+ @ApiOperation(value = "下载导入模板", notes = "下载导入模板")
|
|
|
@GetMapping("/download")
|
|
|
- public void importFileTemplate(HttpServletResponse response){
|
|
|
- List<ExamStudentDTO> list= new ArrayList<ExamStudentDTO>();
|
|
|
+ public void importFileTemplate(HttpServletResponse response) {
|
|
|
+ List<ExamStudentDTO> list = new ArrayList<ExamStudentDTO>();
|
|
|
ExportUtils.exportEXCEL("考生导入模板", ExamStudentDTO.class, list, response);
|
|
|
}
|
|
|
|
|
@@ -229,13 +250,13 @@ public class ExamStudentApi {
|
|
|
|
|
|
@ApiOperation(value = "复制考试学生", notes = "复制")
|
|
|
@PostMapping("/copy/{sourceExamId}/{targetExamId}")
|
|
|
- public ResponseEntity copyExamStudent(@PathVariable Long sourceExamId,@PathVariable Long targetExamId) {
|
|
|
+ public ResponseEntity copyExamStudent(@PathVariable Long sourceExamId, @PathVariable Long targetExamId) {
|
|
|
try {
|
|
|
- examStudentService.copyExamStudent(sourceExamId,targetExamId);
|
|
|
+ examStudentService.copyExamStudent(sourceExamId, targetExamId);
|
|
|
return new ResponseEntity(HttpStatus.OK);
|
|
|
- } catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- return new ResponseEntity(new ErrorMsg(e.getMessage()),HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ return new ResponseEntity(new ErrorMsg(e.getMessage()), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
}
|
|
|
}
|
|
|
}
|