From 79e43ccffd15afcd99934ee43b706f6133398079 Mon Sep 17 00:00:00 2001 From: 啊鑫 <t2856754968@163.com> Date: 星期一, 07 七月 2025 15:29:56 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- MESApplication/Startup.cs | 33 ++++++++++++++++++++++++++++++++- 1 files changed, 32 insertions(+), 1 deletions(-) diff --git a/MESApplication/Startup.cs b/MESApplication/Startup.cs index 20a55e3..b764775 100644 --- a/MESApplication/Startup.cs +++ b/MESApplication/Startup.cs @@ -1,4 +1,8 @@ -锘縰sing Microsoft.OpenApi.Models; +锘縰sing System.Reflection; +using MES.Service.Dto.@base; +using MES.Service.util; +using MESApplication.Filter; +using Microsoft.OpenApi.Models; using Newtonsoft.Json; using Newtonsoft.Json.Serialization; using Swashbuckle.AspNetCore.SwaggerUI; @@ -13,6 +17,8 @@ public Startup(IConfiguration configuration) { Configuration = configuration; + + new AppsettingsUtility().Initial(configuration); } public IConfiguration Configuration { get; } @@ -21,11 +27,20 @@ public void ConfigureServices(IServiceCollection services) { services.AddControllers(); + + // 璇诲彇 绯荤粺 璁剧疆骞舵敞鍏ュ埌鏈嶅姟涓� + services.Configure<AppSettings>( + Configuration.GetSection("AppSettings")); + services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "MESApplication.Api", Version = "v1" }); + var xmlFile = + $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; + var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); + c.IncludeXmlComments(xmlPath, true); }); //閰嶇疆JSON.NET @@ -57,6 +72,18 @@ "OPTIONS") ); }); + + #region 鎺ュ彛琛屽姩杩囨护鍣� + + services.AddControllers(options => + { + options.Filters.Add(new ActionFilter()); + }); + var serviceProvider = services.BuildServiceProvider(); + ActionFilter.LoggerError = + serviceProvider.GetRequiredService<ILogger<ActionFilter>>(); + + #endregion } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. @@ -83,5 +110,9 @@ app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); + + ////////////////////////// + + /////////////////////////// } } \ No newline at end of file -- Gitblit v1.9.3