|
@@ -28,6 +28,8 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
@@ -68,6 +70,8 @@ import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
|
|
@RequestMapping("${app.api.root}/exam_student")
|
|
|
public class ExamStudentApi {
|
|
|
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(ExamStudentApi.class);
|
|
|
+
|
|
|
@Autowired
|
|
|
ExamStudentRepo examStudentRepo;
|
|
|
|
|
@@ -111,7 +115,7 @@ public class ExamStudentApi {
|
|
|
examStudent.setOrgId(accessUser.getOrgId());
|
|
|
}
|
|
|
} else {
|
|
|
- return new ResponseEntity(HttpStatus.NOT_FOUND);
|
|
|
+ return new ResponseEntity(new ErrorMsg("无访问权限"),HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
}
|
|
|
return new ResponseEntity(examStudentService.getAllExamStudent(examStudent,
|
|
|
new PageRequest(curPage, pageSize,new Sort(Direction.DESC,"id"))), HttpStatus.OK);
|
|
@@ -122,15 +126,19 @@ public class ExamStudentApi {
|
|
|
*/
|
|
|
@ApiOperation(value = "查询重考考生", notes = "查询重考考生")
|
|
|
@PostMapping("/reexamineStudents/{curPage}/{pageSize}")
|
|
|
- public ResponseEntity getReexamineStudents(@RequestBody CommonExamStudent examStudentSpecification,@PathVariable Integer curPage,@PathVariable Integer pageSize){
|
|
|
+ public ResponseEntity getReexamineStudents(@RequestBody CommonExamStudent examStudentSpecification,
|
|
|
+ @PathVariable Integer curPage,
|
|
|
+ @PathVariable Integer pageSize){
|
|
|
try{
|
|
|
Page<ExamStudent> pageExamStudents = examStudentService.getReexamineStudent(examStudentSpecification, curPage, pageSize);
|
|
|
- if(pageExamStudents==null||pageExamStudents.getContent()==null||pageExamStudents.getContent().size()==0){
|
|
|
- return new ResponseEntity(new ErrorMsg("无数据",null), HttpStatus.OK);
|
|
|
+ if(pageExamStudents == null
|
|
|
+ || pageExamStudents.getContent() == null
|
|
|
+ || pageExamStudents.getContent().size() == 0){
|
|
|
+ return new ResponseEntity(new ErrorMsg("无数据"), HttpStatus.OK);
|
|
|
}
|
|
|
return new ResponseEntity(pageExamStudents,HttpStatus.OK);
|
|
|
}catch(Exception e){
|
|
|
- e.printStackTrace();
|
|
|
+ log.error("调用失败:",e);
|
|
|
return new ResponseEntity(new ErrorMsg("调用失败"),HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
}
|
|
|
}
|
|
@@ -174,7 +182,7 @@ public class ExamStudentApi {
|
|
|
ExamStudent saveExamStu = examStudentService.saveExamStudent(examStudent);
|
|
|
return new ResponseEntity(saveExamStu, HttpStatus.OK);
|
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+ log.error("新增失败:",e);
|
|
|
return new ResponseEntity(new ErrorMsg(e.getMessage()), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
}
|
|
|
}
|
|
@@ -191,14 +199,15 @@ public class ExamStudentApi {
|
|
|
ExamStudent saveExamStu = examStudentService.saveExamStudent(examStudent);
|
|
|
return new ResponseEntity(saveExamStu, HttpStatus.OK);
|
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+ log.error("更新失败:",e);
|
|
|
return new ResponseEntity(new ErrorMsg(e.getMessage()), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "更新考试学生缺考状态", notes = "更新缺考")
|
|
|
@PutMapping("/{id}")
|
|
|
- public ResponseEntity<ExamStudent> getExamStudentById(@PathVariable Long id, @RequestParam boolean finished) {
|
|
|
+ public ResponseEntity<ExamStudent> getExamStudentById(@PathVariable Long id,
|
|
|
+ @RequestParam boolean finished) {
|
|
|
ExamStudent examStudent = examStudentRepo.findOne(id);
|
|
|
examStudent.setFinished(finished);
|
|
|
//进入考试时,判断考试次数是否小于考试信息(ecs_exam)中的考试次数,如果是,考试次数加一
|
|
@@ -212,13 +221,14 @@ public class ExamStudentApi {
|
|
|
@ApiOperation(value = "按ID删除考试学生", notes = "删除")
|
|
|
@DeleteMapping("/{id}")
|
|
|
public ResponseEntity deleteExamStudent(@PathVariable String id) {
|
|
|
- List<Long> examStuIds = Stream.of(id.split(",")).map(s -> Long.parseLong(s.trim()))
|
|
|
+ List<Long> examStuIds = Stream.of(id.split(","))
|
|
|
+ .map(s -> Long.parseLong(s.trim()))
|
|
|
.collect(Collectors.toList());
|
|
|
try {
|
|
|
examStudentService.deleteExamStudent(examStuIds);
|
|
|
return new ResponseEntity(HttpStatus.OK);
|
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+ log.error("删除失败:",e);
|
|
|
return new ResponseEntity(new ErrorMsg(e.getMessage()), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
}
|
|
|
}
|
|
@@ -230,7 +240,7 @@ public class ExamStudentApi {
|
|
|
examStudentService.deleteExamStudents(examId);
|
|
|
return new ResponseEntity(HttpStatus.OK);
|
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+ log.error("删除失败:",e);
|
|
|
return new ResponseEntity(new ErrorMsg(e.getMessage()), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
}
|
|
|
}
|
|
@@ -243,7 +253,7 @@ public class ExamStudentApi {
|
|
|
List<ExcelError> excelErrors = examStudentService.importExamStudent(examId, new FileInputStream(tempFile));
|
|
|
return new ResponseEntity(excelErrors, HttpStatus.OK);
|
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+ log.error("导入失败:",e);
|
|
|
return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
}
|
|
|
}
|
|
@@ -296,7 +306,7 @@ public class ExamStudentApi {
|
|
|
examStudentService.copyExamStudent(sourceExamId, targetExamId);
|
|
|
return new ResponseEntity(HttpStatus.OK);
|
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+ log.error("复制失败:",e);
|
|
|
return new ResponseEntity(new ErrorMsg(e.getMessage()), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
}
|
|
|
}
|
|
@@ -310,7 +320,6 @@ public class ExamStudentApi {
|
|
|
Map<String, Integer> result = new HashMap<>();
|
|
|
result.put("finished", finished);
|
|
|
result.put("unFinished", unFinished);
|
|
|
-
|
|
|
return result;
|
|
|
}
|
|
|
|