|
@@ -15,6 +15,10 @@ using TEAMModelOS.SDK.DI;
|
|
|
using System.IdentityModel.Tokens.Jwt;
|
|
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
|
|
using Microsoft.IdentityModel.Tokens;
|
|
|
+using TEAMModelOS.Filter;
|
|
|
+using TEAMModelOS.SDK.Helper.Common.ReflectorExtensions;
|
|
|
+using System.Reflection;
|
|
|
+using TEAMModelOS.SDK.Extension;
|
|
|
|
|
|
namespace TEAMModelAPI
|
|
|
{
|
|
@@ -89,6 +93,7 @@ namespace TEAMModelAPI
|
|
|
//HttpContextAccessor,并用来访问HttpContext。(提供組件或非控制器服務存取HttpContext)
|
|
|
services.AddHttpContextAccessor();
|
|
|
services.Configure<Option>(options => Configuration.GetSection("Option").Bind(options));
|
|
|
+
|
|
|
}
|
|
|
|
|
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
|
@@ -109,6 +114,16 @@ namespace TEAMModelAPI
|
|
|
{
|
|
|
endpoints.MapControllers();
|
|
|
});
|
|
|
+#if DEBUG
|
|
|
+ //在开发模式时,自检 [ApiToken(Auth = "1")] 有重复的接口
|
|
|
+ List<ApiTokenAttribute> auths = new List<ApiTokenAttribute>();
|
|
|
+ List<Attribute> attributes = ReflectorExtensions.GetMethodCustomAttribute<ApiTokenAttribute>(new string[] { "TEAMModelAPI" });
|
|
|
+ attributes.ForEach(x => {
|
|
|
+ ApiTokenAttribute attribute = (ApiTokenAttribute)x;
|
|
|
+ auths.Add(attribute);
|
|
|
+ });
|
|
|
+ auths.GroupBy(x => x.Auth).ToList().ForEach(x => { if (x.Count() > 1) { throw new Exception($"接口定义Auth重复{x.ToList()}"); } });
|
|
|
+#endif
|
|
|
}
|
|
|
}
|
|
|
}
|