using APT.BaseData.Domain.IServices.FM;
using APT.Infrastructure.Api.Redis;
using APT.Infrastructure.Core;
using APT.PF.WebApi.Models;
using APT.Utility;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using APT.Infrastructure.Api;
namespace APT.PF.WebApi.Controllers.Api
{
    [Route("api/PF/VerifyPhone")]
    public class VerifyPhoneCodeController :CommonApiController
    {
        /// 
        /// 手机验证码
        /// 
        /// 
        [HttpGet, Route("PhoneVerifyCode")]
        public JsonActionResult PhoneNumberVerifyCode(string orgId,string uid, string random)
        {
            return SafeExecute(() =>
            {
                string code = VerifyCodeHelper.GetSingleObj().CreateVerifyCode(VerifyCodeHelper.VerifyCodeType.NumberVerifyCode, 6);
                Dictionary dicNCode = new Dictionary();
                dicNCode.Add("time", DateTime.Now.AddSeconds(60).ToString());
                dicNCode.Add("code", code);
                CsRedisManager.StringSet(SessionKey.VERIFY_MESSAGE_CODE + uid, dicNCode);
                //var serice = ServiceLocator.Instance.GetService();               
                //return serice.SendMessage(new Guid(orgId), new Guid(uid), code);
                return true;
            });
        }
        /// 
        /// APP手机验证码
        /// 
        /// 
        [HttpGet, Route("AppPhoneVerifyCode")]
        public JsonActionResult AppPhoneVerifyCode(string phone)
        {
            return SafeExecute(() =>
            {
                string code = VerifyCodeHelper.GetSingleObj().CreateVerifyCode(VerifyCodeHelper.VerifyCodeType.NumberVerifyCode, 6);
                Dictionary dicNCode = new Dictionary();
                dicNCode.Add("time", DateTime.Now.AddSeconds(60).ToString());
                dicNCode.Add("code", code);
                CsRedisManager.StringSet(SessionKey.VERIFY_MESSAGE_CODE + phone, dicNCode);
                //var serice = ServiceLocator.Instance.GetService();
                //return serice.SendMessage(phone, code);
                return true;
            });
        }
    }
}