This commit is contained in:
movingsam 2026-02-19 21:40:22 +08:00
parent d4aff05804
commit 7a9fcf9fc1
2 changed files with 25 additions and 4 deletions

View File

@ -6,6 +6,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NetCorePal.Extensions.AspNetCore" />
<PackageReference Include="OpenIddict.Quartz" />
<PackageReference Include="Swashbuckle.AspNetCore" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design">

View File

@ -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<ApplicationDbContext>(options =>
options.UseOpenIddict();
});
builder.Services.AddDbContext<PlatformDbContext>(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