新增禁用特性

parent 9ae0577b
......@@ -58,6 +58,13 @@ public ActionsFilter(ILoggerFactory factory, IMemoryCache cache, IHostingEnviron
// return;
//}
}
var disable = ((ControllerActionDescriptor)context.ActionDescriptor).MethodInfo.GetCustomAttributes(typeof(DisableAttribute), true);
if (disable.Length > 0)
{
var response = new ApiResponse(ResponseType.Disable, "接口已禁用");
context.Result = new ObjectResult(response);
return;
}
//验证请求参数
if (!context.ModelState.IsValid)
{
......@@ -132,4 +139,7 @@ public ActionsFilter(ILoggerFactory factory, IMemoryCache cache, IHostingEnviron
[AttributeUsage(AttributeTargets.Method)]
public class NoVerifyAttribute : Attribute { }
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
public class DisableAttribute : Attribute { }
}
......@@ -12,5 +12,6 @@ public enum ResponseType
TokenError = 4,
NotFound = 5,
ParameterError = 6,
Disable = 7,
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment