using MAX.Core.DependencyInjection; using MAX.Core.Helpers; using Store.Client.HttpExtension; using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Text; using System.Threading.Tasks; namespace Store.Client.Apis { /// /// 公共基础数据Api /// public partial class CommonApi : AppApiRequestBase, ITransientDependency { #region 公共基础 /// /// 获取服务器时间校准时间 /// public DateTime GetServerTime() { HttpResult result = ServerRequest(new HttpItem { URL = $"{_config.Host}/time.php" }); if (result.StatusCode == HttpStatusCode.OK) { if (DateTime.TryParse(result.Html, out DateTime dt)) { return dt; } else { throw new Exception("连接服务器失败,将导致无法登录"); } } return DateTime.Now; } /// /// 获取签名验证配置 /// public string GetAuthConfig() { HttpItem item = new HttpItem(); item.URL = $"{_config.Host}?obj=api/config&act=auth_config"; HttpResult result = ServerRequest(item); if (result.StatusCode == HttpStatusCode.OK) { return result.Html; } return ""; } /// /// 获取缓存服务集群负载比例 /// public string GetCacheServerRatio() { HttpItem item = new HttpItem(); item.URL = _config.Host + "?" + _config.ObjUrl + "config&act=cache_service_mode"; item.Method = MethodType.Post; //item.SignUser(); HttpResult result = ServerRequest(item); if (result.StatusCode == HttpStatusCode.OK) { return result.Html; } return ""; } #endregion ///// ///// 获取服务器图片缓存 ///// ///// ///// //public HttpResult GetImageCache(string imgUrl) //{ // long id = MD5Helper.GetLong(imgUrl); // HttpItem item = new HttpItem(); // item.Method = MethodType.Post; // item.URL = _config.Host + "?" + _config.ObjUrl + "add_img"; // item.Postdata = "act=get&table=" + Math.Abs(id % 1024) + "&id=" + id; // return ServerRequest(item); //} #region 默认服务接口 /// /// common&act=get_agent_ip /// public HttpResult GetAgentIp(string postdata = "") { return Post("common&act=get_agent_ip", postdata); } /// /// config&act=get_service_url /// public HttpResult GetServiceUrl(string postdata = "") { return Post("config&act=get_service_url", postdata); } /// /// cookies&act=save /// public HttpResult SaveCookies(string postdata = "") { return Post("cookies&act=save", postdata); } /// /// data_change&act=get_cache_title /// public HttpResult GetCacheTitle(string postdata = "") { return Post("data_change&act=get_cache_title", postdata); } /// /// data_change&act=get_pid /// public HttpResult GetPid(string postdata = "") { return Post("data_change&act=get_pid", postdata); } /// /// decode&act=get /// public HttpResult GetDecode(string postdata = "") { return Post("decode&act=get", postdata); } /// /// decode&act=getx /// public HttpResult GetDecodeList(string postdata = "") { return Post("decode&act=getx", postdata); } /// /// get_taobao_sign&act=get_tb_sign /// public HttpResult GetTaobaoSign(string postdata = "") { return Post("get_taobao_sign&act=get_tb_sign", postdata); } /// /// nav_group_list /// public HttpResult GetNavGroupList(string postdata = "") { return Post("nav_group_list", postdata); } /// /// oem_config&act=get_config_info /// public HttpResult GetOemConfigInfo(string postdata = "") { return Post("oem_config&act=get_config_info", postdata); } /// /// oem_config&act=get_version /// public HttpResult GetOemVersion(string postdata = "") { return Post("oem_config&act=get_version", postdata); } /// /// regedit /// public HttpResult Regedit(string postdata = "") { return PostPublic("regedit", postdata); } /// /// reset_password /// public HttpResult ResetPassword(string postdata = "") { return PostPublic("reset_password", postdata); } /// /// sign /// public HttpResult GetPackageSign(string postdata = "") { return Post("sign", postdata); } /// /// sign&act=get&type={type}&client_id={clientId} /// public HttpResult GetSign(string type, string clientId, string postdata = "") { return Post("sign&act=get&type=" + type + "&client_id=" + clientId, postdata); } /// /// sms_gate /// public HttpResult SmsGate(string postdata = "") { return PostPublic("sms_gate", postdata); } /// /// upid&act=getx&page={page} /// public HttpResult GetUpidList(int page, string postdata = "") { return Post("upid&act=getx&page=" + page, postdata); } #endregion #region 默认兼容接口 /// /// update/get_update_new /// public HttpResult DefaultUpdateGetUpdateNew(string postdata = "") { return PostDefault("update/get_update_new", postdata); } #endregion } }