public void OnAuthorization(AuthorizationFilterContext context) { var request = context.HttpContext.Request; if (!request.Headers.ContainsKey("DYLS-Applet") || !request.Headers.ContainsKey("X-Scanner-Ud")) { context.Result = JsonResultHelper.Fail(); return; } string timesTamp = request.Headers["timesTamp"]; string signature = request.Headers["signature"]; string appletKey = ConfigHelper.Get(ConfigHelper.Wx_Applet_Key); string appId = ConfigHelper.Get(ConfigHelper.Wx_Applet_AppId); string apiSignature = SystemHelper.Md5(timesTamp + appletKey + appId); if (signature != apiSignature) { context.Result = JsonResultHelper.Fail(); return; } }
/// <summary> /// 用在子类中直接调取 /// </summary> /// <typeparam name="I"></typeparam> /// <typeparam name="Model"></typeparam> /// <param name="obj"></param> /// <returns></returns> protected virtual ActionResult Delete <I, Model>([FromBody] long id) where Model : DbBaseModel where I : class, IDalBase <Model> { var result = DalFactory.GetInstance <I>().DeleteById(id); if (result > 0) { return(JsonResultHelper.Success()); } return(JsonResultHelper.Fail()); }
/// <summary> /// 用在子类中直接调取 /// </summary> /// <typeparam name="I"></typeparam> /// <typeparam name="Model"></typeparam> /// <param name="obj"></param> /// <returns></returns> protected virtual ActionResult UpdateSort <I, Model>([FromBody] dynamic obj) where Model : DbBaseModel where I : class, IDalBase <Model> { var id = (long)obj.id; var val = (long)obj.val; var result = DalFactory.GetInstance <I>().UpdateSort(id, val); if (result > 0) { return(JsonResultHelper.Success()); } return(JsonResultHelper.Fail()); }
/// <summary> /// 用在子类中直接调取 /// </summary> /// <typeparam name="I"></typeparam> /// <typeparam name="Model"></typeparam> /// <param name="obj"></param> /// <returns></returns> protected virtual ActionResult Update <I, Model>([FromBody] Model obj) where Model : DbBaseModel where I : class, IDalBase <Model> { if (obj == null) { return(JsonResultHelper.InvalidParameter()); } var result = DalFactory.GetInstance <I>().Update(obj); if (result > 0) { return(JsonResultHelper.Success()); } return(JsonResultHelper.Fail()); }
/// <summary> /// 用在子类中直接调取 /// </summary> /// <typeparam name="I"></typeparam> /// <typeparam name="Model"></typeparam> /// <param name="obj"></param> /// <returns></returns> protected virtual ActionResult Add <I, Model>([FromBody] Model obj) where Model : DbBaseModel where I : class, IDalBase <Model> { if (obj == null) { return(JsonResultHelper.InvalidParameter()); } //检测对象是否是拥有排序值, 如果有的话, 需要设置一下 var dal = DalFactory.GetInstance <I>(); var result = dal.Insert(obj); if (result > 0) { return(JsonResultHelper.Success(result)); } return(JsonResultHelper.Fail()); }