|
@@ -0,0 +1,62 @@
|
|
|
+package cn.com.qmth.examcloud.core.basic.api.provider;
|
|
|
+
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
|
+import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.StudentFaceCloudService;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.request.SaveStudentFaceInfoReq;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.response.SaveStudentFaceInfoResp;
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.StudentFaceInfoRepo;
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.StudentRepo;
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.entity.Student;
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.entity.StudentFaceInfo;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping("${$rmp.cloud.basic}" + "demo")
|
|
|
+public class StudentFaceCloudServiceProvider extends ControllerSupport
|
|
|
+ implements
|
|
|
+ StudentFaceCloudService {
|
|
|
+
|
|
|
+ private static final long serialVersionUID = 8674317301051207328L;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ StudentFaceInfoRepo studentFaceInfoRepo;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ StudentRepo studentRepo;
|
|
|
+
|
|
|
+ @ApiOperation(value = "保存学生人脸数据")
|
|
|
+ @PostMapping("saveStudentFaceInfo")
|
|
|
+ @Override
|
|
|
+ public SaveStudentFaceInfoResp saveStudentFaceInfo(@RequestBody SaveStudentFaceInfoReq req) {
|
|
|
+
|
|
|
+ String photoPath = req.getPhotoPath();
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(photoPath)) {
|
|
|
+ throw new StatusException("B-412001", "photoPath is blank");
|
|
|
+ }
|
|
|
+
|
|
|
+ Long studentId = req.getStudentId();
|
|
|
+ Student student = studentRepo.findOne(studentId);
|
|
|
+ student.setPhotoPath(req.getPhotoPath());
|
|
|
+
|
|
|
+ StudentFaceInfo studentFaceInfo = studentFaceInfoRepo.findByStudentId(student.getId());
|
|
|
+ if (studentFaceInfo == null) {
|
|
|
+ studentFaceInfo = new StudentFaceInfo();
|
|
|
+ studentFaceInfo.setStudent(student);
|
|
|
+ }
|
|
|
+
|
|
|
+ studentFaceInfo.setFaceSetToken(req.getFaceSetToken());
|
|
|
+ studentFaceInfo.setFaceToken(req.getFaceToken());
|
|
|
+ studentFaceInfoRepo.save(studentFaceInfo);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|