From df3597792dbab9b15047ec43140644705c7c13c3 Mon Sep 17 00:00:00 2001 From: "DESKTOP-M4V1LH5\\Jin" Date: Tue, 6 Nov 2018 16:36:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- COMCMS.Web/Controllers/api/IndexController.cs | 21 +++++++++++-------- COMCMS.Web/Filter/CheckFilter.cs | 4 ++-- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/COMCMS.Web/Controllers/api/IndexController.cs b/COMCMS.Web/Controllers/api/IndexController.cs index 56f975a..2b65044 100644 --- a/COMCMS.Web/Controllers/api/IndexController.cs +++ b/COMCMS.Web/Controllers/api/IndexController.cs @@ -7,12 +7,15 @@ using COMCMS.Common; using COMCMS.Core; using COMCMS.Web.Filter; using XCode; +using COMCMS.Web.Common; // For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 namespace COMCMS.Web.Controllers.api { - + [Produces("application/json")] + [Route("api/[controller]/[action]")] + [WebAPIHandleError] public class IndexController : Controller { // GET: api/ @@ -23,7 +26,7 @@ namespace COMCMS.Web.Controllers.api return cfg; } - //#region 测试验签 + #region 测试验签 /// /// 测试验签 /// @@ -32,13 +35,13 @@ namespace COMCMS.Web.Controllers.api /// /// /// - //[HttpGet] - //[CheckFilter] - //public ReJSON CheckSign(string id, string random = "", string timeStamp = "", string signature = "") - //{ - // return new ReJSON("验签成功!"); - //} - //#endregion + [HttpGet] + [CheckFilter] + public ReJson CheckSign(string id, string random = "", string timeStamp = "", string signature = "") + { + return new ReJson("验签成功!"); + } + #endregion //#region 测试出错 //[HttpGet] diff --git a/COMCMS.Web/Filter/CheckFilter.cs b/COMCMS.Web/Filter/CheckFilter.cs index 022423d..ded9ebb 100644 --- a/COMCMS.Web/Filter/CheckFilter.cs +++ b/COMCMS.Web/Filter/CheckFilter.cs @@ -37,7 +37,7 @@ namespace COMCMS.Web.Filter var notVali = ValiSignature(context.HttpContext); - if (notVali == null) + if (notVali != null) { await context.HttpContext.Response.WriteAsync(notVali.ToJson()); } @@ -74,7 +74,7 @@ namespace COMCMS.Web.Filter } //没有签名返回错误 if (string.IsNullOrEmpty(signature)) - throw new Exception("signature Is Null"); + return new ReJson(40004, "signature 为空!"); if (!MySign.CheckSign(pars, signature)) {