using System; using System.Collections.Generic; using System.Linq; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Microsoft.AspNetCore.Authorization; using System.Web; using LitJson; using Library; namespace MySystem.Areas.Api.Controllers.v1 { [Area("Api")] [Route("Api/v1/[controller]/[action]")] public class MobileCodeCheckController : BaseController { public MobileCodeCheckController(IHttpContextAccessor accessor) : base(accessor) { } #region 我的-发送验证码 // [Authorize] public JsonResult SendSms(string value) { value = DesDecrypt(value); JsonData data = JsonMapper.ToObject(value); AppResultJson result = SendSmsDo(value); return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data }); } public AppResultJson SendSmsDo(string value) { JsonData data = JsonMapper.ToObject(value); Dictionary Obj = new Dictionary(); string Mobile = data["Mobile"].ToString(); //手机号 string check = RedisDbconn.Instance.Get("MobileCodeCheck:" + Mobile); if (check == "") { return new AppResultJson() { Status = "1", Info = "", Data = Obj }; } string CheckCode = function.get_Random(6); RedisDbconn.Instance.Set("MobileCodeCheck:" + Mobile, CheckCode); RedisDbconn.Instance.SetExpire("MobileCodeCheck:" + Mobile, 300); SendSMS.Instance.Do(Mobile, CheckCode); //发送短信 return new AppResultJson() { Status = "1", Info = "", Data = Obj }; } #endregion } }