public ActionResult BindFace(FaceRegisterRequest request) { FaceRecognitionResponse response = BaiduApiBll.FaceRegister(request.ImgPath, request.ImgType, GetCurrentUser().StudentId.ToString(), request.UserInfo); if (response.error_code == 0) { StudentInfoBll studentInfoBll = new StudentInfoBll(); studentInfoBll.AddStudentPassport(GetCurrentUser().StudentId, StudentAccountSourceEnum.人脸识别, response.result.face_token, ""); return(Json(new JsonResponse <FaceRecognitionResponse>() { Data = response, ErrorCode = 1, ErrorMsg = "绑定成功" })); } return(Json(new JsonResponse <FaceRecognitionResponse>() { Data = response, ErrorCode = 0, ErrorMsg = "绑定失败" })); }
public ActionResult BindFace(FaceBindInputModel inputModel) { if (SmsCookie.GetSmsCode == null || !SmsCookie.GetSmsCode.Check(inputModel.Phone, inputModel.SmsCode)) { return(new JsonResult() { Data = AjaxResponse.Fail(SmsErrorEnum.PhoneCodeFault) }); } StudentInfoBll studentInfoBll = new StudentInfoBll(); var studentPassort = studentInfoBll.GetByPassportKey(inputModel.Phone); if (studentPassort == null) { return(Json(new JsonResponse <int>() { State = false, ErrorCode = -1, ErrorMsg = "用户名不存在" })); } FaceRecognitionResponse response = BaiduApiBll.FaceRegister(inputModel.Image, inputModel.ImageType, studentPassort.Bsp_StudentId.ToString(), ""); if (response.error_code == 0) { studentInfoBll.AddStudentPassport(studentPassort.Bsp_StudentId, StudentAccountSourceEnum.人脸识别, response.result.face_token, ""); return(Json(new JsonResponse <FaceRecognitionResponse>() { Data = response, ErrorCode = 1, ErrorMsg = "绑定成功" })); } return(Json(new JsonResponse <FaceRecognitionResponse>() { Data = response, ErrorCode = 0, ErrorMsg = "绑定失败" })); }