//http://localhost:10010//api/Message/SendMessageCode?phone=18235139350 public IHttpActionResult SendMessageCode(string phone) { LogHelper.WriteLog("SendMessageCode ", phone); SimpleResult result = new SimpleResult(); if (UserAuthorization) { if (ConfigurationManager.AppSettings["isSendMessage"] != null && ConfigurationManager.AppSettings["isSendMessage"].ToString() == "true") { var sendMessageResult = Common.SendMessageCode(phone); if (sendMessageResult != null && sendMessageResult.Status) { //写入到手机号和和数据库 verificationService.Delete(phone); Verification verification = new Verification(); verification.code = Guid.NewGuid().ToString(); verification.VerificationCode = sendMessageResult.Message; verification.Phone = phone; verificationService.CreateVerification(verification); result.Resource = sendMessageResult.Message; result.Status = Result.SUCCEED; } else { result.Msg = "验证码没有发送成功"; result.Status = Result.SYSTEM_ERROR; } } else { //写入到手机号和和数据库 verificationService.Delete(phone); Verification verification = new Verification(); verification.code = Guid.NewGuid().ToString(); Random rd = new Random(); int num = rd.Next(100000, 1000000); verification.VerificationCode = num.ToString(); verification.Phone = phone; verificationService.CreateVerification(verification); result.Resource = num; result.Status = Result.SUCCEED; } } else { result.Status = ResultType; result.Resource = ReAccessToken; result.Msg = TokenMessage; } LogHelper.WriteLog("SendMessageCode result" + Json(result)); return(Json(result)); }