/// <summary> /// /// </summary> /// <returns></returns> public Tuple <bool, string> GetQiNiuHost() { try { var cacheToken = CacheHelper.Get <string> ("qiniuhostkey"); var host = cacheToken.IsNullOrEmpty() ? _redisCommonService.Get <string> ("qiniuhostkey") : cacheToken; if (!host.IsNullOrEmpty()) { return(new Tuple <bool, string> (true, host)); } var result = Helper.HttpRequestHelper.GateWaySync <Result <String> > ("ps.qiniu.host.get", new Dictionary <string, dynamic> ()); if (result.IsSuccess) { CacheHelper.Add("qiniuhostkey", result.Data.Trim('"'), 1440); _redisCommonService.Set("qiniuhostkey", result.Data.Trim('"'), TimeSpan.FromDays(1)); return(new Tuple <bool, string> (true, result.Data.Trim('"'))); } return(new Tuple <bool, string> (false, "")); } catch (Exception e) { return(new Tuple <bool, string> (false, e.Message)); } }
/// <summary> /// 验证短信 /// </summary> /// <param name="phoneNumber"></param> /// <param name="code"></param> /// <param name="type">Constant.SmsCodeType</param> /// <returns></returns> public bool ValidSmsCode(string phoneNumber, string code, string type) { if (string.IsNullOrEmpty(phoneNumber) || string.IsNullOrEmpty(code)) { return(false); } var storeKey = SmsCode_Store_PreKey + phoneNumber + "_" + type; var getCode = _redisCommonService.Get <string>(storeKey); if (!string.IsNullOrEmpty(getCode) && code.Equals(getCode)) { //验证一次,删除该key _redisCommonService.Del(storeKey); return(true); } else { return(false); } }