|
@@ -0,0 +1,87 @@
|
|
|
|
+package cn.com.qmth.examcloud.service.core.api;
|
|
|
|
+
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
|
+
|
|
|
|
+import java.util.Date;
|
|
|
|
+
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.PutMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
+
|
|
|
|
+import cn.com.qmth.examcloud.common.util.ErrorMsg;
|
|
|
|
+import cn.com.qmth.examcloud.service.core.entity.Student;
|
|
|
|
+import cn.com.qmth.examcloud.service.core.entity.StudentFaceInfo;
|
|
|
|
+import cn.com.qmth.examcloud.service.core.repo.StudentFaceInfoRepo;
|
|
|
|
+import cn.com.qmth.examcloud.service.core.repo.StudentRepo;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 学生照片API
|
|
|
|
+ */
|
|
|
|
+@RestController
|
|
|
|
+@RequestMapping("${app.api.root}/studentFaceInfo")
|
|
|
|
+public class StudentFaceInfoApi {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ StudentFaceInfoRepo studentFaceInfoRepo;
|
|
|
|
+ @Autowired
|
|
|
|
+ StudentRepo studentRepo;
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value="按身份证查询",notes="查询")
|
|
|
|
+ @GetMapping("/identityNumber")
|
|
|
|
+ public ResponseEntity findByIdentityNumber(@RequestParam Long orgId,@RequestParam String identityNumber){
|
|
|
|
+ Student student = studentRepo.findByIdentityNumber(identityNumber);
|
|
|
|
+ if(student == null){
|
|
|
|
+ return new ResponseEntity(new ErrorMsg("该学生不存在"),HttpStatus.OK);
|
|
|
|
+ }
|
|
|
|
+ StudentFaceInfo studentFaceInfo = studentFaceInfoRepo.findByStudentId(student.getId());
|
|
|
|
+ if(studentFaceInfo == null){
|
|
|
|
+ studentFaceInfo = new StudentFaceInfo();
|
|
|
|
+ studentFaceInfo.setStudent(student);
|
|
|
|
+ }
|
|
|
|
+ return new ResponseEntity(studentFaceInfo,HttpStatus.OK);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value="按学号查询",notes="查询")
|
|
|
|
+ @GetMapping("/studentCode")
|
|
|
|
+ public ResponseEntity findByStudentCode(@RequestParam Long orgId,@RequestParam String studentCode){
|
|
|
|
+ Student student = studentRepo.findByUserRootOrgIdAndStudentCode(orgId, studentCode);
|
|
|
|
+ if(student == null){
|
|
|
|
+ return new ResponseEntity(new ErrorMsg("该学生不存在"),HttpStatus.OK);
|
|
|
|
+ }
|
|
|
|
+ StudentFaceInfo studentFaceInfo = studentFaceInfoRepo.findByStudentId(student.getId());
|
|
|
|
+ if(studentFaceInfo == null){
|
|
|
|
+ studentFaceInfo = new StudentFaceInfo();
|
|
|
|
+ studentFaceInfo.setStudent(student);
|
|
|
|
+ }
|
|
|
|
+ return new ResponseEntity(studentFaceInfo,HttpStatus.OK);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value="按ID查询",notes="ID查询")
|
|
|
|
+ @GetMapping("/{id}")
|
|
|
|
+ public ResponseEntity getById(@PathVariable Long id){
|
|
|
|
+ return new ResponseEntity(studentFaceInfoRepo.findOne(id),HttpStatus.OK);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value="新增学生照片信息",notes="新增")
|
|
|
|
+ @PostMapping
|
|
|
|
+ public ResponseEntity add(@RequestBody StudentFaceInfo studentFaceInfo){
|
|
|
|
+ studentFaceInfo.setCreateTime(new Date());
|
|
|
|
+ return new ResponseEntity(studentFaceInfoRepo.save(studentFaceInfo),HttpStatus.CREATED);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value="更新学生照片信息",notes="更新")
|
|
|
|
+ @PutMapping
|
|
|
|
+ public ResponseEntity update(@RequestBody StudentFaceInfo studentFaceInfo){
|
|
|
|
+ studentFaceInfo.setUpdateTime(new Date());
|
|
|
|
+ return new ResponseEntity(studentFaceInfoRepo.save(studentFaceInfo),HttpStatus.OK);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|