简化webapi

This commit is contained in:
2018-12-04 21:39:11 +08:00
parent 9fe99a0843
commit fdd55859a8
5 changed files with 100 additions and 55 deletions
@@ -11,7 +11,6 @@ using XCode;
using System.Web; using System.Web;
using COMCMS.Web.Filter; using COMCMS.Web.Filter;
using NewLife.Log; using NewLife.Log;
using static COMCMS.Web.Models.APIModels;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Senparc.Weixin.WxOpen; using Senparc.Weixin.WxOpen;
@@ -11,7 +11,6 @@ using XCode;
using System.Web; using System.Web;
using COMCMS.Web.Filter; using COMCMS.Web.Filter;
using NewLife.Log; using NewLife.Log;
using static COMCMS.Web.Models.APIModels;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Senparc.Weixin.WxOpen; using Senparc.Weixin.WxOpen;
+1 -1
View File
@@ -11,10 +11,10 @@ using XCode;
using System.Web; using System.Web;
using COMCMS.Web.Filter; using COMCMS.Web.Filter;
using NewLife.Log; using NewLife.Log;
using static COMCMS.Web.Models.APIModels;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Senparc.Weixin.WxOpen; using Senparc.Weixin.WxOpen;
using COMCMS.Web.Models;
namespace COMCMS.Web.Controllers.api namespace COMCMS.Web.Controllers.api
{ {
+1 -1
View File
@@ -120,7 +120,7 @@ namespace COMCMS.Web.Filter
string timeStamp = pars["timeStamp"]; string timeStamp = pars["timeStamp"];
//判断时间有效性 //判断时间有效性
DateTime postTime = Utils.StampToDateTime(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); return new ReJson(40004, "signature 错误!", 1);
} }
+49 -2
View File
@@ -4,8 +4,6 @@ using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace COMCMS.Web.Models namespace COMCMS.Web.Models
{
public class APIModels
{ {
#region 修改我的个人资料Model #region 修改我的个人资料Model
public class APIModMyInfo public class APIModMyInfo
@@ -57,5 +55,54 @@ namespace COMCMS.Web.Models
} }
#endregion #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;
}
/// <summary>
/// 返回代码 0 为正确
/// </summary>
public int code { get; set; } = 40000;
/// <summary>
/// 提示语
/// </summary>
public string message { get; set; }
/// <summary>
/// 是否重新加载
/// </summary>
public int isReload { get; set; } = 0;
/// <summary>
/// 数据详情 object
/// </summary>
public object detail { get; set; }
}
#endregion
} }