From fdd55859a87e8f2ef6d08c229dde1c1377672d62 Mon Sep 17 00:00:00 2001 From: "DESKTOP-M4V1LH5\\Jin" Date: Tue, 4 Dec 2018 21:39:11 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=80=E5=8C=96webapi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/api/ArticleController.cs | 1 - .../Controllers/api/ProductController.cs | 1 - COMCMS.Web/Controllers/api/UserController.cs | 2 +- COMCMS.Web/Filter/CheckFilter.cs | 2 +- COMCMS.Web/Models/APIModels.cs | 149 ++++++++++++------ 5 files changed, 100 insertions(+), 55 deletions(-) diff --git a/COMCMS.Web/Controllers/api/ArticleController.cs b/COMCMS.Web/Controllers/api/ArticleController.cs index 262077c..48be6e8 100644 --- a/COMCMS.Web/Controllers/api/ArticleController.cs +++ b/COMCMS.Web/Controllers/api/ArticleController.cs @@ -11,7 +11,6 @@ using XCode; using System.Web; using COMCMS.Web.Filter; using NewLife.Log; -using static COMCMS.Web.Models.APIModels; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Senparc.Weixin.WxOpen; diff --git a/COMCMS.Web/Controllers/api/ProductController.cs b/COMCMS.Web/Controllers/api/ProductController.cs index e2df8fe..6c142f7 100644 --- a/COMCMS.Web/Controllers/api/ProductController.cs +++ b/COMCMS.Web/Controllers/api/ProductController.cs @@ -11,7 +11,6 @@ using XCode; using System.Web; using COMCMS.Web.Filter; using NewLife.Log; -using static COMCMS.Web.Models.APIModels; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Senparc.Weixin.WxOpen; diff --git a/COMCMS.Web/Controllers/api/UserController.cs b/COMCMS.Web/Controllers/api/UserController.cs index af06165..1f9d664 100644 --- a/COMCMS.Web/Controllers/api/UserController.cs +++ b/COMCMS.Web/Controllers/api/UserController.cs @@ -11,10 +11,10 @@ using XCode; using System.Web; using COMCMS.Web.Filter; using NewLife.Log; -using static COMCMS.Web.Models.APIModels; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Senparc.Weixin.WxOpen; +using COMCMS.Web.Models; namespace COMCMS.Web.Controllers.api { diff --git a/COMCMS.Web/Filter/CheckFilter.cs b/COMCMS.Web/Filter/CheckFilter.cs index 738175d..4b6fbae 100644 --- a/COMCMS.Web/Filter/CheckFilter.cs +++ b/COMCMS.Web/Filter/CheckFilter.cs @@ -120,7 +120,7 @@ namespace COMCMS.Web.Filter string timeStamp = pars["timeStamp"]; //判断时间有效性 DateTime postTime = Utils.StampToDateTime(timeStamp); - if (postTime < DateTime.Now.AddSeconds(-120))//30秒有效期 + if (postTime < DateTime.UtcNow.AddSeconds(-120))//30秒有效期 { return new ReJson(40004, "signature 错误!", 1); } diff --git a/COMCMS.Web/Models/APIModels.cs b/COMCMS.Web/Models/APIModels.cs index e899a0a..94948c7 100644 --- a/COMCMS.Web/Models/APIModels.cs +++ b/COMCMS.Web/Models/APIModels.cs @@ -5,57 +5,104 @@ using System.Threading.Tasks; namespace COMCMS.Web.Models { - public class APIModels + #region 修改我的个人资料Model + public class APIModMyInfo { - #region 修改我的个人资料Model - public class APIModMyInfo - { - public string RealName { get; set; } - public string Tel { get; set; } - public string Weixin { get; set; } - public string Alipay { get; set; } - public string BankCardNO { get; set; } - public string Bank { get; set; } - public string SessionKey { get; set; } - } - #endregion - - #region 小程序获得用户信息 - /// - /// 小程序获得用户信息 - /// - public class WXAppUserInfo - { - /// - /// 用户名 - /// - public string nickName { get; set; } - /// - /// 性别 0 未知,1 男,2女 - /// - public int gender { get; set; } - /// - /// 语言 - /// - public string language { get; set; } - /// - /// 城市 - /// - public string city { get; set; } - /// - /// 省份 - /// - public string province { get; set; } - /// - /// 国家 - /// - public string country { get; set; } - /// - /// 用户头像 - /// - public string avatarUrl { get; set; } - } - - #endregion + public string RealName { get; set; } + public string Tel { get; set; } + public string Weixin { get; set; } + public string Alipay { get; set; } + public string BankCardNO { get; set; } + public string Bank { get; set; } + public string SessionKey { get; set; } } + #endregion + + #region 小程序获得用户信息 + /// + /// 小程序获得用户信息 + /// + public class WXAppUserInfo + { + /// + /// 用户名 + /// + public string nickName { get; set; } + /// + /// 性别 0 未知,1 男,2女 + /// + public int gender { get; set; } + /// + /// 语言 + /// + public string language { get; set; } + /// + /// 城市 + /// + public string city { get; set; } + /// + /// 省份 + /// + public string province { get; set; } + /// + /// 国家 + /// + public string country { get; set; } + /// + /// 用户头像 + /// + public string avatarUrl { get; set; } + } + + #endregion + + #region 通用返回信息 + public class ReJson + { + public ReJson(string message) + { + this.message = message; + code = 0; + } + + public ReJson(int code, string message) + { + this.code = code; + this.message = message; + } + + public ReJson(int code, string message, int isReload) + { + this.code = code; + this.message = message; + this.isReload = isReload; + } + + public ReJson(int code, string message, object detail) + { + this.code = code; + this.message = message; + this.detail = detail; + } + + /// + /// 返回代码 0 为正确 + /// + public int code { get; set; } = 40000; + + /// + /// 提示语 + /// + public string message { get; set; } + /// + /// 是否重新加载 + /// + public int isReload { get; set; } = 0; + + /// + /// 数据详情 object + /// + public object detail { get; set; } + } + #endregion }