This commit is contained in:
2018-11-06 16:36:00 +08:00
parent c5b64d5466
commit df3597792d
2 changed files with 14 additions and 11 deletions
+12 -9
View File
@@ -7,12 +7,15 @@ using COMCMS.Common;
using COMCMS.Core; using COMCMS.Core;
using COMCMS.Web.Filter; using COMCMS.Web.Filter;
using XCode; using XCode;
using COMCMS.Web.Common;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 // For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
namespace COMCMS.Web.Controllers.api namespace COMCMS.Web.Controllers.api
{ {
[Produces("application/json")]
[Route("api/[controller]/[action]")]
[WebAPIHandleError]
public class IndexController : Controller public class IndexController : Controller
{ {
// GET: api/<controller> // GET: api/<controller>
@@ -23,7 +26,7 @@ namespace COMCMS.Web.Controllers.api
return cfg; return cfg;
} }
//#region 测试验签 #region 测试验签
/// <summary> /// <summary>
/// 测试验签 /// 测试验签
/// </summary> /// </summary>
@@ -32,13 +35,13 @@ namespace COMCMS.Web.Controllers.api
/// <param name="timeStamp"></param> /// <param name="timeStamp"></param>
/// <param name="signature"></param> /// <param name="signature"></param>
/// <returns></returns> /// <returns></returns>
//[HttpGet] [HttpGet]
//[CheckFilter] [CheckFilter]
//public ReJSON CheckSign(string id, string random = "", string timeStamp = "", string signature = "") public ReJson CheckSign(string id, string random = "", string timeStamp = "", string signature = "")
//{ {
// return new ReJSON("验签成功!"); return new ReJson("验签成功!");
//} }
//#endregion #endregion
//#region 测试出错 //#region 测试出错
//[HttpGet] //[HttpGet]
+2 -2
View File
@@ -37,7 +37,7 @@ namespace COMCMS.Web.Filter
var notVali = ValiSignature(context.HttpContext); var notVali = ValiSignature(context.HttpContext);
if (notVali == null) if (notVali != null)
{ {
await context.HttpContext.Response.WriteAsync(notVali.ToJson()); await context.HttpContext.Response.WriteAsync(notVali.ToJson());
} }
@@ -74,7 +74,7 @@ namespace COMCMS.Web.Filter
} }
//没有签名返回错误 //没有签名返回错误
if (string.IsNullOrEmpty(signature)) if (string.IsNullOrEmpty(signature))
throw new Exception("signature Is Null"); return new ReJson(40004, "signature 为空!");
if (!MySign.CheckSign(pars, signature)) if (!MySign.CheckSign(pars, signature))
{ {