已完成管理后台第二批 ASP.NET Core 10 迁移:
学校创建、修改 班级创建、修改 管理员创建、修改 管理员密码重置 自主注册开关 写入与审计日志保持同一事务 停用或重置管理员后自动清除其会话
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Eis.Application.Administration;
|
||||
using Eis.Infrastructure.Administration;
|
||||
using System.Text.Json.Nodes;
|
||||
|
||||
namespace Eis.Web.Administration;
|
||||
|
||||
@@ -23,6 +24,24 @@ public static class NativeAdminReadEndpoints
|
||||
Execute(context, service.GetAdminsAsync(Token(context), cancellationToken)));
|
||||
endpoints.MapGet("/api/admin/exams", (HttpContext context, IAdminReadService service, CancellationToken cancellationToken) =>
|
||||
Execute(context, service.GetExamsAsync(Token(context), cancellationToken)));
|
||||
|
||||
if (!options.NativeOrganizationWritesEnabled) return endpoints;
|
||||
endpoints.MapPost("/api/admin/schools", (HttpContext context, JsonObject body, IAdminOrganizationService service, CancellationToken cancellationToken) =>
|
||||
Execute(context, service.CreateSchoolAsync(Token(context), body, cancellationToken)));
|
||||
endpoints.MapPatch("/api/admin/schools/{schoolId}", (HttpContext context, string schoolId, JsonObject body, IAdminOrganizationService service, CancellationToken cancellationToken) =>
|
||||
Execute(context, service.UpdateSchoolAsync(Token(context), schoolId, body, cancellationToken)));
|
||||
endpoints.MapPost("/api/admin/classes", (HttpContext context, JsonObject body, IAdminOrganizationService service, CancellationToken cancellationToken) =>
|
||||
Execute(context, service.CreateClassAsync(Token(context), body, cancellationToken)));
|
||||
endpoints.MapPatch("/api/admin/classes/{classId}", (HttpContext context, string classId, JsonObject body, IAdminOrganizationService service, CancellationToken cancellationToken) =>
|
||||
Execute(context, service.UpdateClassAsync(Token(context), classId, body, cancellationToken)));
|
||||
endpoints.MapPost("/api/admin/admins", (HttpContext context, JsonObject body, IAdminOrganizationService service, CancellationToken cancellationToken) =>
|
||||
Execute(context, service.CreateAdminAsync(Token(context), body, cancellationToken)));
|
||||
endpoints.MapPatch("/api/admin/admins/{adminId}", (HttpContext context, string adminId, JsonObject body, IAdminOrganizationService service, CancellationToken cancellationToken) =>
|
||||
Execute(context, service.UpdateAdminAsync(Token(context), adminId, body, cancellationToken)));
|
||||
endpoints.MapPost("/api/admin/admins/{adminId}/reset-password", (HttpContext context, string adminId, IAdminOrganizationService service, CancellationToken cancellationToken) =>
|
||||
Execute(context, service.ResetAdminPasswordAsync(Token(context), adminId, cancellationToken)));
|
||||
endpoints.MapPut("/api/admin/settings/self-registration", (HttpContext context, JsonObject body, IAdminOrganizationService service, CancellationToken cancellationToken) =>
|
||||
Execute(context, service.UpdateSelfRegistrationAsync(Token(context), body, cancellationToken)));
|
||||
return endpoints;
|
||||
}
|
||||
|
||||
|
||||
+14
-4
@@ -45,7 +45,8 @@ var candidateMigrationOptions = CandidateMigrationOptions.FromEnvironment(
|
||||
var adminMigrationOptions = AdminMigrationOptions.FromEnvironment(
|
||||
builder.Configuration.GetValue<bool>("AdminMigration:NativeReadsEnabled"),
|
||||
authenticationOptions.NativeEnabled,
|
||||
authenticationOptions.SharesLegacySessions);
|
||||
authenticationOptions.SharesLegacySessions,
|
||||
builder.Configuration.GetValue<bool>("AdminMigration:NativeOrganizationWritesEnabled"));
|
||||
builder.Services.AddEisInfrastructure(
|
||||
DatabaseOptions.FromEnvironment(applicationRoot, builder.Environment.IsProduction()),
|
||||
DocumentVerificationOptions.FromEnvironment(builder.Environment.IsProduction()),
|
||||
@@ -100,9 +101,18 @@ app.MapGet("/health/migration", async (LegacyApiProxy proxy, CancellationToken c
|
||||
administration = new
|
||||
{
|
||||
nativeReadsEnabled = adminMigrationOptions.NativeReadsEnabled,
|
||||
nativeRoutes = adminMigrationOptions.NativeReadsEnabled
|
||||
? new[] { "GET context", "GET dashboard", "GET schools", "GET school-organization", "GET admins", "GET exams" }
|
||||
: []
|
||||
nativeOrganizationWritesEnabled = adminMigrationOptions.NativeOrganizationWritesEnabled,
|
||||
nativeRoutes = (adminMigrationOptions.NativeReadsEnabled
|
||||
? new[] { "GET context", "GET dashboard", "GET schools", "GET school-organization", "GET admins", "GET exams" }
|
||||
: [])
|
||||
.Concat(adminMigrationOptions.NativeOrganizationWritesEnabled
|
||||
? new[]
|
||||
{
|
||||
"POST/PATCH schools", "POST/PATCH classes", "POST/PATCH admins",
|
||||
"POST admin password reset", "PUT self-registration setting"
|
||||
}
|
||||
: [])
|
||||
.ToArray()
|
||||
},
|
||||
features = MigrationFeatureCatalog.Current(authenticationOptions.NativeEnabled, candidateMigrationOptions.NativeEnabled)
|
||||
}, statusCode: statusCode);
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
"NativeEnabled": false
|
||||
},
|
||||
"AdminMigration": {
|
||||
"NativeReadsEnabled": false
|
||||
"NativeReadsEnabled": false,
|
||||
"NativeOrganizationWritesEnabled": false
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
|
||||
Reference in New Issue
Block a user