|
@@ -104,21 +104,33 @@ public class ExamStudentApi {
|
|
|
@PostMapping()
|
|
|
public ResponseEntity addExamStudent(HttpServletRequest request,
|
|
|
@RequestBody ExamStudent examStudent) {
|
|
|
- AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
|
|
|
- if(accessUser != null){
|
|
|
- examStudent.setRootOrgId(accessUser.getRootOrgId());
|
|
|
+ try {
|
|
|
+ AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
|
|
|
+ if (accessUser != null) {
|
|
|
+ examStudent.setRootOrgId(accessUser.getRootOrgId());
|
|
|
+ }
|
|
|
+ Exam exam = examRepo.findOne(examStudent.getExam().getId());
|
|
|
+ examStudent.setExam(exam);
|
|
|
+ ExamStudent saveExamStu = examStudentService.saveExamStudent(examStudent);
|
|
|
+ return new ResponseEntity(saveExamStu, HttpStatus.OK);
|
|
|
+ } catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ return new ResponseEntity(new ErrorMsg(e.getMessage()),HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
}
|
|
|
- Exam exam = examRepo.findOne(examStudent.getExam().getId());
|
|
|
- examStudent.setExam(exam);
|
|
|
- return new ResponseEntity<ExamStudent>(examStudentService.saveExamStudent(examStudent), HttpStatus.OK);
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "更新考试学生", notes = "更新")
|
|
|
@PutMapping()
|
|
|
public ResponseEntity updateExamStudent(@RequestBody ExamStudent examStudent) {
|
|
|
- Exam exam = examRepo.findOne(examStudent.getExam().getId());
|
|
|
- examStudent.setExam(exam);
|
|
|
- return new ResponseEntity(examStudentService.saveExamStudent(examStudent), HttpStatus.OK);
|
|
|
+ try {
|
|
|
+ Exam exam = examRepo.findOne(examStudent.getExam().getId());
|
|
|
+ examStudent.setExam(exam);
|
|
|
+ ExamStudent saveExamStu = examStudentService.saveExamStudent(examStudent);
|
|
|
+ return new ResponseEntity(saveExamStu, HttpStatus.OK);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return new ResponseEntity(new ErrorMsg(e.getMessage()), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "更新考试学生缺考状态", notes = "更新缺考")
|