From 356c47fb0ea1a642784e85c82833141d065bc4bc Mon Sep 17 00:00:00 2001 From: sunpengfei <i@angelzzz.com> Date: 星期二, 05 八月 2025 09:22:25 +0800 Subject: [PATCH] feat:动态控制器开发 --- FlexJobApi.Core/FlexJobApiCoreStartup.cs | 22 +++++++++++++++++++--- 1 files changed, 19 insertions(+), 3 deletions(-) diff --git a/FlexJobApi.Core/FlexJobApiCoreStartup.cs b/FlexJobApi.Core/FlexJobApiCoreStartup.cs index e665ae2..c913fe3 100644 --- a/FlexJobApi.Core/FlexJobApiCoreStartup.cs +++ b/FlexJobApi.Core/FlexJobApiCoreStartup.cs @@ -41,6 +41,8 @@ options.WithStackFrame = true; }); + services.AddConfigurableOptions<AliyunOptions>(); + services.AddComponent<EventBusServiceComponent>(); services.AddComponent<DistributedCacheServiceComponent>(); @@ -48,22 +50,29 @@ services.AddMediatR(cfg => cfg.RegisterServicesFromAssemblies(App.Assemblies.ToArray())); services.AddHostedService<XmlDocBuildHostedService>(); + services.AddHostedService<BuildDynamicControllersHostedService>(); services.AddJwt<JwtHandler>(enableGlobalAuthorize: true); services.AddCorsAccessor(); + 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>(); } - 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 +90,7 @@ app.UseUnifyResultStatusCodes(); - app.UseHttpsRedirection(); + //app.UseHttpsRedirection(); app.UseRouting(); @@ -92,10 +101,17 @@ app.UseInject(string.Empty); + app.UseSpecificationDocuments(); + app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); + + //lifetime.ApplicationStarted.Register(async () => + //{ + // await ResourceUtils.BuildDynamicControllersAsync(); + //}); } } } -- Gitblit v1.9.1