From 7a9fcf9fc1927d9c11c1bd1a2807ad451ea0d156 Mon Sep 17 00:00:00 2001 From: movingsam Date: Thu, 19 Feb 2026 21:40:22 +0800 Subject: [PATCH] debug --- Fengling.AuthService.csproj | 1 + Program.cs | 28 ++++++++++++++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/Fengling.AuthService.csproj b/Fengling.AuthService.csproj index 0fa79c9..9dd6279 100644 --- a/Fengling.AuthService.csproj +++ b/Fengling.AuthService.csproj @@ -6,6 +6,7 @@ + diff --git a/Program.cs b/Program.cs index d887dcb..f4d8b51 100644 --- a/Program.cs +++ b/Program.cs @@ -1,14 +1,18 @@ +using System.Reflection; using Fengling.AuthService.Configuration; using Fengling.AuthService.Data; using Fengling.AuthService.Models; +using Fengling.Platform.Infrastructure; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; using Microsoft.OpenApi; +using NetCorePal.Extensions.DependencyInjection; using OpenTelemetry; using OpenTelemetry.Resources; using OpenTelemetry.Trace; using Serilog; +using SeedData = Fengling.AuthService.Data.SeedData; var builder = WebApplication.CreateBuilder(args); @@ -27,6 +31,14 @@ builder.Services.AddDbContext(options => options.UseOpenIddict(); }); + +builder.Services.AddDbContext(options => +{ + options.UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection")); + options.UseOpenIddict(); +}); + + builder.Services.AddRazorPages(); builder.Services.AddControllersWithViews(); @@ -52,15 +64,23 @@ builder.Services.AddOpenTelemetry() resource.AddService("Fengling.AuthService")) .WithTracing(tracing => tracing.AddAspNetCoreInstrumentation() - .AddHttpClientInstrumentation() - .AddSource("OpenIddict.Server.AspNetCore") - .AddOtlpExporter()); + .AddHttpClientInstrumentation() + .AddSource("OpenIddict.Server.AspNetCore") + .AddOtlpExporter()); builder.Services.AddControllersWithViews(); builder.Services.AddHealthChecks() .AddNpgSql(builder.Configuration.GetConnectionString("DefaultConnection")!); + +builder.Services.AddRepositories(typeof(ApplicationDbContext).Assembly, typeof(PlatformDbContext).Assembly); +builder.Services.AddMediatR(x => x.RegisterServicesFromAssemblies(typeof(PlatformDbContext).Assembly + , Assembly.GetExecutingAssembly()) + .AddCommandLockBehavior() + .AddKnownExceptionValidationBehavior() + .AddUnitOfWorkBehaviors() +); builder.Services.AddSwaggerGen(options => { options.SwaggerDoc("v1", new OpenApiInfo @@ -119,4 +139,4 @@ app.MapRazorPages(); app.MapControllers(); app.MapHealthChecks("/health"); -app.Run(); +app.Run(); \ No newline at end of file