本轮迁移已完成,生产运行链路现已切换为纯 ASP.NET Core 10。
主要完成: 补齐招生学校计划、投档审核、报到、扫码、补录等原生接口。 新增 SQLite/MySQL 空库初始化及默认审批流、号码规则。 删除 Node 兼容代理,未知 API 直接返回原生 404。 Docker、Compose、Gitea CI 全部切换到 Eis.Web.dll。 CKEditor 已固化到 Web 发布资源,不再依赖 node_modules。 新增纯 .NET 冒烟脚本:[smoke-dotnet-native.ps1 (line 1)](C:/Users/BI/Documents/EIS-dotnet/scripts/smoke-dotnet-native.ps1:1)。 迁移状态已更新:[MIGRATION.md (line 14)](C:/Users/BI/Documents/EIS-dotnet/MIGRATION.md:14)。 容器入口见 [Dockerfile (line 31)](C:/Users/BI/Documents/EIS-dotnet/Dockerfile:31)。
This commit is contained in:
+14
-25
@@ -1,4 +1,3 @@
|
||||
using System.Net;
|
||||
using Eis.Infrastructure.Authentication;
|
||||
using Eis.Infrastructure.Administration;
|
||||
using Eis.Infrastructure.Candidate;
|
||||
@@ -13,7 +12,6 @@ using Eis.Web.Authentication;
|
||||
using Eis.Web.Administration;
|
||||
using Eis.Web.Candidate;
|
||||
using Eis.Web.Frontend;
|
||||
using Eis.Web.Legacy;
|
||||
using Eis.Web.Public;
|
||||
|
||||
var applicationRoot = ApplicationPaths.FindApplicationRoot();
|
||||
@@ -21,19 +19,6 @@ EnvironmentFile.Load(applicationRoot);
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.WebHost.ConfigureKestrel(options => options.AddServerHeader = false);
|
||||
builder.Services.Configure<LegacyNodeOptions>(builder.Configuration.GetSection(LegacyNodeOptions.SectionName));
|
||||
builder.Services.AddHttpClient<LegacyApiProxy>((services, client) =>
|
||||
{
|
||||
var options = services.GetRequiredService<Microsoft.Extensions.Options.IOptions<LegacyNodeOptions>>().Value;
|
||||
client.BaseAddress = options.BaseUrl;
|
||||
client.Timeout = TimeSpan.FromSeconds(30);
|
||||
client.DefaultRequestHeaders.UserAgent.ParseAdd("Eis.AspNetCore.Migration/1.0");
|
||||
}).ConfigurePrimaryHttpMessageHandler(() => new SocketsHttpHandler
|
||||
{
|
||||
AllowAutoRedirect = false,
|
||||
AutomaticDecompression = DecompressionMethods.None,
|
||||
UseCookies = false
|
||||
});
|
||||
builder.Services.AddProblemDetails();
|
||||
builder.Services.AddSingleton<IPublicSiteConfiguration, PublicSiteConfiguration>();
|
||||
var authenticationOptions = AuthenticationOptions.FromEnvironment(
|
||||
@@ -68,6 +53,7 @@ builder.Services.AddEisInfrastructure(
|
||||
adminMigrationOptions);
|
||||
|
||||
var app = builder.Build();
|
||||
await app.Services.InitializeEisDatabaseAsync();
|
||||
app.Services.EnsureNativeAuthenticationReady(authenticationOptions);
|
||||
|
||||
app.UseExceptionHandler();
|
||||
@@ -86,17 +72,13 @@ app.MapGet("/health/live", () => Results.Json(new
|
||||
framework = ".NET 10"
|
||||
}));
|
||||
|
||||
app.MapGet("/health/migration", async (
|
||||
LegacyApiProxy proxy,
|
||||
IApplicationCache cache,
|
||||
CancellationToken cancellationToken) =>
|
||||
app.MapGet("/health/migration", (IApplicationCache cache) =>
|
||||
{
|
||||
var legacyAvailable = await proxy.IsAvailableAsync(cancellationToken);
|
||||
var statusCode = legacyAvailable ? StatusCodes.Status200OK : StatusCodes.Status503ServiceUnavailable;
|
||||
return Results.Json(new
|
||||
{
|
||||
status = legacyAvailable ? "healthy" : "degraded",
|
||||
legacyApiAvailable = legacyAvailable,
|
||||
status = "healthy",
|
||||
legacyApiAvailable = false,
|
||||
legacyApiRemoved = true,
|
||||
cache = new
|
||||
{
|
||||
status = cache.Status,
|
||||
@@ -202,7 +184,7 @@ app.MapGet("/health/migration", async (
|
||||
.ToArray()
|
||||
},
|
||||
features = MigrationFeatureCatalog.Current(authenticationOptions.NativeEnabled, candidateMigrationOptions.NativeEnabled)
|
||||
}, statusCode: statusCode);
|
||||
}, statusCode: StatusCodes.Status200OK);
|
||||
});
|
||||
|
||||
app.MapNativePublicEndpoints();
|
||||
@@ -220,7 +202,14 @@ string[] methods =
|
||||
HttpMethods.Delete,
|
||||
HttpMethods.Options
|
||||
];
|
||||
app.MapMethods("/api/{**path}", methods, (HttpContext context, LegacyApiProxy proxy) => proxy.ForwardAsync(context));
|
||||
app.MapMethods("/api/{**path}", methods, (HttpContext context) =>
|
||||
{
|
||||
context.Response.Headers.CacheControl = "no-store";
|
||||
context.Response.Headers["X-EIS-Implementation"] = "aspnet-core";
|
||||
return Results.Json(
|
||||
new { ok = false, message = "API 接口不存在" },
|
||||
statusCode: StatusCodes.Status404NotFound);
|
||||
});
|
||||
|
||||
app.MapFrontendAssets();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user