From 27076e2f1c080e6d8a86a7bd2120d9f2839b13e7 Mon Sep 17 00:00:00 2001 From: zhengyiming <540361168@qq.com> Date: 星期五, 08 八月 2025 17:12:31 +0800 Subject: [PATCH] Merge branch 'master' of http://120.26.58.240:8888/r/ApiFlexJob --- FlexJobApi.Core/FlexJobApiCoreStartup.cs | 54 ++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 42 insertions(+), 12 deletions(-) diff --git a/FlexJobApi.Core/FlexJobApiCoreStartup.cs b/FlexJobApi.Core/FlexJobApiCoreStartup.cs index e665ae2..de3bf71 100644 --- a/FlexJobApi.Core/FlexJobApiCoreStartup.cs +++ b/FlexJobApi.Core/FlexJobApiCoreStartup.cs @@ -1,4 +1,5 @@ -锘縰sing Furion; +锘縰sing Consul; +using Furion; using Furion.EventBus; using MediatR; using Microsoft.AspNetCore.Builder; @@ -19,31 +20,40 @@ { public void ConfigureServices(IServiceCollection services) { + services.AddHealthChecks(); + services.AddConsoleFormatter(options => { options.WithTraceId = true; - options.WithStackFrame = true; }); services.AddFileLogging(options => { options.WithTraceId = true; - options.WithStackFrame = true; options.FileNameRule = fileName => { - return string.Format(fileName, DateTime.UtcNow); // 濡傛灉鏄湰鍦版椂闂翠娇鐢� DateTime.Now + return string.Format(fileName, DateTime.Now); }; }); - services.AddDatabaseLogging<DatabaseLoggingWriter>(options => - { - options.WithTraceId = true; - options.WithStackFrame = true; - }); + //services.AddDatabaseLogging<DatabaseLoggingWriter>(options => + //{ + // options.WithTraceId = true; + //}); + + services.AddConfigurableOptions<AliyunOptions>(); + + services.AddComponent<ConsulServiceComponent>(); services.AddComponent<EventBusServiceComponent>(); services.AddComponent<DistributedCacheServiceComponent>(); + + services.AddHttpRemote(); + services.AddSingleton<ResourceHttpUtils>(); + services.AddSingleton<AliyunSmsUtils>(); + services.AddSingleton<WxmpUtils>(); + services.AddScoped<SmsUtils>(); services.AddMediatR(cfg => cfg.RegisterServicesFromAssemblies(App.Assemblies.ToArray())); @@ -53,17 +63,27 @@ services.AddCorsAccessor(); + services.AddHostedService<BuildDynamicControllersHostedService>(); + + services.AddSpecificationDocuments(options => + { + options.OperationFilter<CustomOperationIdFilter>(); + options.SchemaFilter<EnumSchemaFilter>(); + }); + services.AddControllers() .AddNewtonsoftJson(options => { - options.SerializerSettings.Converters.Add(new StringEnumConverter()); + //options.SerializerSettings.Converters.Add(new StringEnumConverter()); }) .AddFriendlyException() .AddDataValidation() .AddInjectWithUnifyResult<FriendlyResultProvider>(); + + services.AddMvcFilter<ResourceActionFilter>(); } - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IHostApplicationLifetime lifetime) { // 瑙f瀽浜嬩欢鎬荤嚎鍙戝竷鏈嶅姟 var eventPublisher = app.ApplicationServices.GetRequiredService<IEventPublisher>(); @@ -81,7 +101,7 @@ app.UseUnifyResultStatusCodes(); - app.UseHttpsRedirection(); + //app.UseHttpsRedirection(); app.UseRouting(); @@ -92,10 +112,20 @@ app.UseInject(string.Empty); + app.UseSpecificationDocuments(); + app.UseEndpoints(endpoints => { endpoints.MapControllers(); + endpoints.MapHealthChecks("/healthz"); }); + + app.UseComponent<ConsulApplicationComponent>(env); + + //lifetime.ApplicationStarted.Register(async () => + //{ + // await ResourceUtils.BuildDynamicControllersAsync(); + //}); } } } -- Gitblit v1.9.1