|
@@ -1,35 +1,35 @@
|
|
|
package com.qmth.themis.exam.api;
|
|
|
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.Map;
|
|
|
-
|
|
|
-import javax.annotation.Resource;
|
|
|
-
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
-
|
|
|
import com.qmth.themis.business.bean.exam.FaceVerifyBean;
|
|
|
import com.qmth.themis.business.bean.exam.FaceVerifyParamBean;
|
|
|
-import com.qmth.themis.business.service.TOeFaceVerifyHistoryService;
|
|
|
-import com.qmth.themis.common.exception.BusinessException;
|
|
|
-import com.qmth.themis.common.util.Result;
|
|
|
-import com.qmth.themis.common.util.ResultUtil;
|
|
|
import com.qmth.themis.business.dto.MqDto;
|
|
|
import com.qmth.themis.business.enums.MqTagEnum;
|
|
|
import com.qmth.themis.business.enums.MqTopicEnum;
|
|
|
import com.qmth.themis.business.service.MqDtoService;
|
|
|
-
|
|
|
+import com.qmth.themis.business.service.TOeFaceVerifyHistoryService;
|
|
|
+import com.qmth.themis.business.util.JacksonUtil;
|
|
|
+import com.qmth.themis.common.exception.BusinessException;
|
|
|
+import com.qmth.themis.common.util.Result;
|
|
|
+import com.qmth.themis.common.util.ResultUtil;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiResponse;
|
|
|
import io.swagger.annotations.ApiResponses;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* 人脸验证
|
|
|
- *
|
|
|
+ *
|
|
|
* @Description:
|
|
|
* @Author: xiatian
|
|
|
* @Date: 2020-07-31
|
|
@@ -38,48 +38,50 @@ import io.swagger.annotations.ApiResponses;
|
|
|
@RestController
|
|
|
@RequestMapping("/${prefix.url.exam}/face")
|
|
|
public class TEFaceController {
|
|
|
+ private final static Logger log = LoggerFactory.getLogger(TEFaceController.class);
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ TOeFaceVerifyHistoryService faceVerifyHistoryService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ MqDtoService mqDtoService;
|
|
|
+
|
|
|
+ @ApiOperation(value = "人脸验证结果")
|
|
|
+ @RequestMapping(value = "/verify", method = RequestMethod.POST)
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "人脸验证信息")})
|
|
|
+ @Transactional
|
|
|
+ public Result verify(@RequestBody FaceVerifyParamBean param) {
|
|
|
+ log.info("FaceVerifyParamBean:{}", JacksonUtil.parseJson(param));
|
|
|
+ if (param.getRecordId() == null) {
|
|
|
+ throw new BusinessException("考试记录id不能为空");
|
|
|
+ }
|
|
|
+ if (param.getType() == null) {
|
|
|
+ throw new BusinessException("type不能为空");
|
|
|
+ }
|
|
|
+ if (param.getPhotoUrl() == null) {
|
|
|
+ throw new BusinessException("照片文件URL不能为空");
|
|
|
+ }
|
|
|
+ if (param.getSimilarity() == null) {
|
|
|
+ throw new BusinessException("相似度分数不能为空");
|
|
|
+ }
|
|
|
+ if (param.getRealness() == null) {
|
|
|
+ throw new BusinessException("真实性结果不能为空");
|
|
|
+ }
|
|
|
+ if (param.getTime() == null) {
|
|
|
+ throw new BusinessException("验证时间不能为空");
|
|
|
+ }
|
|
|
+ if (param.getException() == null) {
|
|
|
+ throw new BusinessException("exception不能为空");
|
|
|
+ }
|
|
|
|
|
|
- @Resource
|
|
|
- TOeFaceVerifyHistoryService faceVerifyHistoryService;
|
|
|
-
|
|
|
- @Resource
|
|
|
- MqDtoService mqDtoService;
|
|
|
|
|
|
- @ApiOperation(value = "人脸验证结果")
|
|
|
- @RequestMapping(value = "/verify", method = RequestMethod.POST)
|
|
|
- @ApiResponses({ @ApiResponse(code = 200, message = "人脸验证信息") })
|
|
|
- @Transactional
|
|
|
- public Result verify(@RequestBody FaceVerifyParamBean param) {
|
|
|
- if (param.getRecordId() == null) {
|
|
|
- throw new BusinessException("考试记录id不能为空");
|
|
|
- }
|
|
|
- if (param.getType() == null) {
|
|
|
- throw new BusinessException("type不能为空");
|
|
|
- }
|
|
|
- if (param.getPhotoUrl() == null) {
|
|
|
- throw new BusinessException("照片文件URL不能为空");
|
|
|
- }
|
|
|
- if (param.getSimilarity() == null) {
|
|
|
- throw new BusinessException("相似度分数不能为空");
|
|
|
- }
|
|
|
- if (param.getRealness() == null) {
|
|
|
- throw new BusinessException("真实性结果不能为空");
|
|
|
- }
|
|
|
- if (param.getTime() == null) {
|
|
|
- throw new BusinessException("验证时间不能为空");
|
|
|
- }
|
|
|
- if (param.getException() == null) {
|
|
|
- throw new BusinessException("exception不能为空");
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- FaceVerifyBean ret = faceVerifyHistoryService.verify(param.getRecordId(), param.getType(), param.getPhotoUrl(),
|
|
|
- param.getFaceCount(),
|
|
|
- param.getSimilarity(),param.getRealness(),param.getTime(),param.getException());
|
|
|
- Map<String, Object> transMap = new HashMap<String, Object>();
|
|
|
- transMap.put("id", ret.getId());
|
|
|
- transMap.put("recordId", param.getRecordId());
|
|
|
- transMap.put("type", param.getType());
|
|
|
+ FaceVerifyBean ret = faceVerifyHistoryService.verify(param.getRecordId(), param.getType(), param.getPhotoUrl(),
|
|
|
+ param.getFaceCount(),
|
|
|
+ param.getSimilarity(), param.getRealness(), param.getTime(), param.getException());
|
|
|
+ Map<String, Object> transMap = new HashMap<String, Object>();
|
|
|
+ transMap.put("id", ret.getId());
|
|
|
+ transMap.put("recordId", param.getRecordId());
|
|
|
+ transMap.put("type", param.getType());
|
|
|
transMap.put("photoUrl", param.getPhotoUrl());
|
|
|
transMap.put("faceCount", param.getFaceCount());
|
|
|
transMap.put("similarity", param.getSimilarity());
|
|
@@ -89,7 +91,7 @@ public class TEFaceController {
|
|
|
//mq发送消息start
|
|
|
MqDto mqDto = new MqDto(MqTopicEnum.themisTopic.getCode(), MqTagEnum.FACE_VERIFY_SAVE.name(), transMap, MqTagEnum.FACE_VERIFY_SAVE, param.getRecordId().toString(), param.getRecordId().toString());
|
|
|
mqDtoService.assembleSendOneWayMsg(mqDto);
|
|
|
- return ResultUtil.ok(ret);
|
|
|
- }
|
|
|
+ return ResultUtil.ok(ret);
|
|
|
+ }
|
|
|
|
|
|
}
|