1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Library;
- using LitJson;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.AspNetCore.Mvc.Filters;
- using MySystem.Models;
- namespace MySystem
- {
- public class GlobalActionFilter : IActionFilter
- {
- public void OnActionExecuted(ActionExecutedContext context)
- {
- //执行方法后执行这
- }
- public void OnActionExecuting(ActionExecutingContext context)
- {
- //执行方法前先执行这
- // var stringArgs = context.ActionArguments.ToList();
- // foreach (var keyValue in stringArgs)
- // {
- // string path = context.ActionDescriptor.AttributeRouteInfo.Template.ToLower();
- // function.WriteLog(path, "拦截器日志");
- // if(keyValue.Key == "value" && AllowApiList().Contains(path))
- // {
- // function.WriteLog(keyValue.Value.ToString(), "拦截器日志");
- // string result = function.PostWebRequest(AppConfig.Base.Host2 + path, "value=" + keyValue.Value.ToString());
- // function.WriteLog(result, "拦截器日志");
- // result = result.Replace("null", "\"\"");
- // result = result.Replace("\"status\"", "\"Status\"");
- // result = result.Replace("\"data\"", "\"Data\"");
- // result = result.Replace("\"other\"", "\"Other\"");
- // result = result.Replace("\"timestamp\"", "\"Timestamp\"");
- // result = result.Replace("\"info\"", "\"Info\"");
- // JsonResult obj = new JsonResult(Newtonsoft.Json.JsonConvert.DeserializeObject<AppResultJson>(result));
- // context.Result = obj;
- // return;
- // }
- // }
- }
- private List<string> AllowApiList()
- {
- List<string> result = new List<string>();
- result.Add("api/v1/merchantaddinfo/add");
- result.Add("api/v1/merchantaddinfo/options");
- result.Add("api/v1/merchantaddinfo/businessscope");
- result.Add("api/v1/merchantaddinfo/detail");
- result.Add("api/v1/merchantinfo/merchantbystatus");
- result.Add("api/v1/merchantinfo/merchantdetailbystatus");
- result.Add("api/v1/consumerorders/pay");
- result.Add("api/v1/openbanktable/list");
- return result;
- }
- }
- }
|