|
@@ -3,8 +3,12 @@ package cn.com.qmth.examcloud.service.examwork.api;
|
|
|
import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
|
|
|
import cn.com.qmth.examcloud.service.examwork.dao.ExamRepo;
|
|
|
import cn.com.qmth.examcloud.service.examwork.entity.Exam;
|
|
|
+import cn.com.qmth.examcloud.service.examwork.service.rpc.OeService;
|
|
|
+import cn.com.qmth.examcloud.service.examwork.util.ImportUtils;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileInputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
@@ -38,6 +42,7 @@ import cn.com.qmth.examcloud.service.examwork.dto.ExamStudentDTO;
|
|
|
import cn.com.qmth.examcloud.service.examwork.entity.ExamStudent;
|
|
|
import cn.com.qmth.examcloud.service.examwork.service.ExamStudentService;
|
|
|
import cn.com.qmth.examcloud.service.examwork.util.ExportUtils;
|
|
|
+import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
|
|
|
|
|
/**
|
|
|
* 考生服务API
|
|
@@ -97,7 +102,7 @@ public class ExamStudentApi {
|
|
|
@ApiOperation(value = "按ID查询考试学生", notes = "ID查询")
|
|
|
@GetMapping("/{id}")
|
|
|
public ResponseEntity<ExamStudent> getExamStudentById(@PathVariable Long id) {
|
|
|
- return new ResponseEntity<ExamStudent>(examStudentService.getExamStudentById(id), HttpStatus.OK);
|
|
|
+ return new ResponseEntity<ExamStudent>(examStudentRepo.findOne(id), HttpStatus.OK);
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "新增考试学生", notes = "新增")
|
|
@@ -143,25 +148,39 @@ 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()))
|
|
|
- .collect(Collectors.toList());
|
|
|
- examStudentRepo.deleteInBatch(examStudentRepo.findByIdIn(examStuIds));
|
|
|
- return new ResponseEntity(HttpStatus.OK);
|
|
|
+ public ResponseEntity deleteExamStudent(@PathVariable Long id) {
|
|
|
+// List<Long> examStuIds = Stream.of(id.split(",")).map(s->Long.parseLong(s.trim()))
|
|
|
+// .collect(Collectors.toList());
|
|
|
+// examStudentRepo.deleteInBatch(examStudentRepo.findByIdIn(examStuIds));
|
|
|
+ try {
|
|
|
+ examStudentService.deleteExamStudent(id);
|
|
|
+ return new ResponseEntity(HttpStatus.OK);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return new ResponseEntity(new ErrorMsg(e.getMessage()),HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "导入考试学生", notes = "导入")
|
|
|
@PostMapping("/import")
|
|
|
- public ResponseEntity importExamStudent(@RequestParam Long examId, @RequestParam MultipartFile file) {
|
|
|
+ public ResponseEntity importExamStudent(@RequestParam Long examId, @RequestParam CommonsMultipartFile file) {
|
|
|
try {
|
|
|
- List<ExcelError> excelErrors = examStudentService.importExamStudent(examId, file.getInputStream());
|
|
|
+ File tempFile = ImportUtils.getUploadFile(file);
|
|
|
+ List<ExcelError> excelErrors = examStudentService.importExamStudent(examId, new FileInputStream(tempFile));
|
|
|
return new ResponseEntity(excelErrors, HttpStatus.OK);
|
|
|
- } catch (IOException e) {
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value="下载导入模板",notes = "下载导入模板")
|
|
|
+ @GetMapping("/download")
|
|
|
+ public void importFileTemplate(HttpServletResponse response){
|
|
|
+ List<ExamStudentDTO> list= new ArrayList<ExamStudentDTO>();
|
|
|
+ ExportUtils.exportEXCEL("考生导入模板", ExamStudentDTO.class, list, response);
|
|
|
+ }
|
|
|
+
|
|
|
// @ApiOperation(value="导入学生照片",notes = "导入")
|
|
|
// @PostMapping("/exam_student/import_photo")
|
|
|
// public ResponseEntity importPhoto(@RequestParam Long examId,@RequestParam MultipartFile file){
|