|
@@ -1,6 +1,8 @@
|
|
|
package cn.com.qmth.examcloud.exchange.outer.api.provider;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
+import java.net.URISyntaxException;
|
|
|
+import java.security.NoSuchAlgorithmException;
|
|
|
import java.util.List;
|
|
|
import java.util.zip.ZipEntry;
|
|
|
import java.util.zip.ZipInputStream;
|
|
@@ -20,15 +22,17 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import cn.com.qmth.examcloud.common.dto.core.StudentFaceInfo;
|
|
|
import cn.com.qmth.examcloud.common.dto.em.ExamStudent;
|
|
|
+import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.commons.base.util.GsonUtil;
|
|
|
import cn.com.qmth.examcloud.commons.web.security.bean.User;
|
|
|
import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
|
import cn.com.qmth.examcloud.exchange.base.exception.DetectNoFaceException;
|
|
|
import cn.com.qmth.examcloud.exchange.base.exception.ExamStudentNotExistException;
|
|
|
+import cn.com.qmth.examcloud.exchange.base.exception.FaceppException;
|
|
|
import cn.com.qmth.examcloud.exchange.base.exception.InvalidJpgException;
|
|
|
+import cn.com.qmth.examcloud.exchange.base.exception.UpYunException;
|
|
|
import cn.com.qmth.examcloud.exchange.base.response.FailureBaseResponse;
|
|
|
import cn.com.qmth.examcloud.exchange.base.response.IBaseResponse;
|
|
|
-import cn.com.qmth.examcloud.exchange.base.response.SuccessBaseResponse;
|
|
|
import cn.com.qmth.examcloud.exchange.outer.service.FaceppService;
|
|
|
import cn.com.qmth.examcloud.exchange.outer.service.client.ExamStudentClient;
|
|
|
import cn.com.qmth.examcloud.exchange.outer.service.client.StudentFaceInfoClient;
|
|
@@ -79,36 +83,25 @@ public class FaceppController extends ControllerSupport {
|
|
|
* @param file
|
|
|
* @param request
|
|
|
* @return
|
|
|
+ * @throws IOException
|
|
|
+ * @throws UpYunException
|
|
|
+ * @throws FaceppException
|
|
|
+ * @throws URISyntaxException
|
|
|
+ * @throws NoSuchAlgorithmException
|
|
|
*/
|
|
|
@PostMapping("/add")
|
|
|
- public ResponseEntity<IBaseResponse> add(@RequestParam MultipartFile file,
|
|
|
- HttpServletRequest request) {
|
|
|
+ public void add(@RequestParam MultipartFile file, HttpServletRequest request) throws Exception {
|
|
|
User accessUser = getAccessUser();
|
|
|
- if (accessUser == null) {
|
|
|
- return new ResponseEntity<>(new FailureBaseResponse("请先登录", null),
|
|
|
- HttpStatus.BAD_REQUEST);
|
|
|
- }
|
|
|
try {
|
|
|
log.debug("fileName =" + file.getOriginalFilename());
|
|
|
faceppService.processOne(accessUser, file.getOriginalFilename(), file.getBytes(),
|
|
|
accessUser.getRootOrgId());
|
|
|
- return new ResponseEntity<>(new SuccessBaseResponse("上传成功", null), HttpStatus.OK);
|
|
|
} catch (InvalidJpgException e) {
|
|
|
- log.error(e.getMessage(), e);
|
|
|
- return new ResponseEntity<>(new FailureBaseResponse("不是一个图片文件", null),
|
|
|
- HttpStatus.NOT_ACCEPTABLE);
|
|
|
+ throw new StatusException("EX-111001", "不是一个图片文件");
|
|
|
} catch (ExamStudentNotExistException e) {
|
|
|
- log.error(e.getMessage(), e);
|
|
|
- return new ResponseEntity<>(new FailureBaseResponse("考生不存在", null),
|
|
|
- HttpStatus.NOT_ACCEPTABLE);
|
|
|
+ throw new StatusException("EX-111002", "考生不存在");
|
|
|
} catch (DetectNoFaceException e) {
|
|
|
- log.error(e.getMessage(), e);
|
|
|
- return new ResponseEntity<>(new FailureBaseResponse("检测不到人脸", null),
|
|
|
- HttpStatus.NOT_ACCEPTABLE);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error(e.getMessage(), e);
|
|
|
- return new ResponseEntity<>(new FailureBaseResponse("上传失败", null),
|
|
|
- HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ throw new StatusException("EX-111003", "检测不到人脸");
|
|
|
}
|
|
|
}
|
|
|
|