|
@@ -0,0 +1,100 @@
|
|
|
|
+package cn.com.qmth.examcloud.core.basic.service.impl;
|
|
|
|
+
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+
|
|
|
|
+import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
|
|
+import cn.com.qmth.examcloud.commons.base.util.UrlUtil;
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.FacesetRepo;
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.StudentFaceRepo;
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.StudentRepo;
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.entity.FacesetEntity;
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.entity.StudentEntity;
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.entity.StudentFaceEntity;
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.service.StudentFaceService;
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.service.bean.StudentFaceInfo;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 类注释
|
|
|
|
+ *
|
|
|
|
+ * @author WANGWEI
|
|
|
|
+ * @date 2018年9月3日
|
|
|
|
+ * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
|
|
|
|
+ */
|
|
|
|
+public class StudentFaceServiceImpl implements StudentFaceService {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ StudentFaceRepo studentFaceRepo;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ FacesetRepo facesetRepo;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ StudentRepo studentRepo;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public StudentFaceEntity saveStudentFace(StudentFaceInfo info) {
|
|
|
|
+ String facesetToken = info.getFacesetToken();
|
|
|
|
+ String faceToken = info.getFaceToken();
|
|
|
|
+ String operator = info.getOperator();
|
|
|
|
+ String photoName = info.getPhotoName();
|
|
|
|
+ Long rootOrgId = info.getRootOrgId();
|
|
|
|
+ Long studentId = info.getStudentId();
|
|
|
|
+
|
|
|
|
+ if (null == studentId) {
|
|
|
|
+ throw new StatusException("B-680001", "studentId is null");
|
|
|
|
+ }
|
|
|
|
+ if (null == rootOrgId) {
|
|
|
|
+ throw new StatusException("B-680002", "rootOrgId is null");
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isBlank(facesetToken)) {
|
|
|
|
+ throw new StatusException("B-680003", "facesetToken is null");
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isBlank(faceToken)) {
|
|
|
|
+ throw new StatusException("B-680004", "faceToken is null");
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isBlank(operator)) {
|
|
|
|
+ throw new StatusException("B-680005", "operator is null");
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isBlank(photoName)) {
|
|
|
|
+ throw new StatusException("B-680006", "photoName is null");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ StudentEntity studentEntity = studentRepo.findOne(studentId);
|
|
|
|
+
|
|
|
|
+ if (null == studentEntity) {
|
|
|
|
+ throw new StatusException("B-680007", "studentEntity is null");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!studentEntity.getRootOrgId().equals(rootOrgId)) {
|
|
|
|
+ throw new StatusException("B-680008", "studentId,rootOrgId is not matched");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String identityNumber = studentEntity.getIdentityNumber();
|
|
|
|
+
|
|
|
|
+ FacesetEntity facesetEntity = facesetRepo.findByFacesetToken(facesetToken);
|
|
|
|
+ if (null == facesetEntity) {
|
|
|
|
+ throw new StatusException("B-680003", "facesetEntity is null");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String photoPath = rootOrgId + "/" + UrlUtil.encode(identityNumber) + "/" + photoName;
|
|
|
|
+ studentEntity.setPhotoPath(photoPath);
|
|
|
|
+
|
|
|
|
+ StudentFaceEntity studentFaceEntity = studentFaceRepo.findOne(studentId);
|
|
|
|
+ if (null == studentFaceEntity) {
|
|
|
|
+ studentFaceEntity = new StudentFaceEntity();
|
|
|
|
+ studentFaceEntity.setStudentId(studentId);
|
|
|
|
+ studentFaceEntity.setCreator(operator);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ studentFaceEntity.setFacesetId(facesetEntity.getId());
|
|
|
|
+ studentFaceEntity.setFaceToken(faceToken);
|
|
|
|
+ studentFaceEntity.setModifiedBy(operator);
|
|
|
|
+
|
|
|
|
+ studentRepo.save(studentEntity);
|
|
|
|
+ StudentFaceEntity saved = studentFaceRepo.save(studentFaceEntity);
|
|
|
|
+
|
|
|
|
+ return saved;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|