PUT /api/candidate/profile
行政区划、学校班级、特长类别校验 证件号码唯一性 自动创建资料审核工作流 资料和用户显示名称原子更新 POST /api/candidate/registrations 资料审核状态、报名时间和科目校验 重复报名防护 自动选择负载最低的审批管理员 报名、科目和审批流原子写入
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
using Eis.Application.Candidate;
|
||||
using Eis.Infrastructure.Candidate;
|
||||
|
||||
namespace Eis.Web.Candidate;
|
||||
|
||||
public static class NativeCandidateEndpoints
|
||||
{
|
||||
public static IEndpointRouteBuilder MapNativeCandidateEndpoints(
|
||||
this IEndpointRouteBuilder endpoints,
|
||||
CandidateMigrationOptions options)
|
||||
{
|
||||
if (!options.NativeEnabled)
|
||||
{
|
||||
return endpoints;
|
||||
}
|
||||
|
||||
endpoints.MapGet("/api/candidate/dashboard", async (
|
||||
HttpContext context,
|
||||
ICandidateService service,
|
||||
CancellationToken cancellationToken) => ToResult(
|
||||
context,
|
||||
await service.GetDashboardAsync(SessionToken(context), cancellationToken)));
|
||||
endpoints.MapGet("/api/candidate/notices", async (
|
||||
HttpContext context,
|
||||
ICandidateService service,
|
||||
CancellationToken cancellationToken) => ToResult(
|
||||
context,
|
||||
await service.GetNoticesAsync(SessionToken(context), cancellationToken)));
|
||||
endpoints.MapGet("/api/candidate/profile", async (
|
||||
HttpContext context,
|
||||
ICandidateService service,
|
||||
CancellationToken cancellationToken) => ToResult(
|
||||
context,
|
||||
await service.GetProfileAsync(SessionToken(context), cancellationToken)));
|
||||
endpoints.MapPut("/api/candidate/profile", async (
|
||||
HttpContext context,
|
||||
System.Text.Json.Nodes.JsonObject request,
|
||||
ICandidateService service,
|
||||
CancellationToken cancellationToken) => ToResult(
|
||||
context,
|
||||
await service.UpdateProfileAsync(SessionToken(context), request, cancellationToken)));
|
||||
endpoints.MapGet("/api/candidate/exams", async (
|
||||
HttpContext context,
|
||||
ICandidateService service,
|
||||
CancellationToken cancellationToken) => ToResult(
|
||||
context,
|
||||
await service.GetExamsAsync(SessionToken(context), cancellationToken)));
|
||||
endpoints.MapGet("/api/candidate/registrations", async (
|
||||
HttpContext context,
|
||||
ICandidateService service,
|
||||
CancellationToken cancellationToken) => ToResult(
|
||||
context,
|
||||
await service.GetRegistrationsAsync(SessionToken(context), cancellationToken)));
|
||||
endpoints.MapPost("/api/candidate/registrations", async (
|
||||
HttpContext context,
|
||||
System.Text.Json.Nodes.JsonObject request,
|
||||
ICandidateService service,
|
||||
CancellationToken cancellationToken) => ToResult(
|
||||
context,
|
||||
await service.CreateRegistrationAsync(SessionToken(context), request, cancellationToken)));
|
||||
|
||||
return endpoints;
|
||||
}
|
||||
|
||||
private static string SessionToken(HttpContext context) =>
|
||||
context.Request.Cookies.TryGetValue("hz_session", out var token) ? token : string.Empty;
|
||||
|
||||
private static IResult ToResult(HttpContext context, CandidateEndpointResult result)
|
||||
{
|
||||
context.Response.Headers.CacheControl = "no-store";
|
||||
context.Response.Headers["X-EIS-Implementation"] = "aspnet-core";
|
||||
return Results.Json(result.Body, statusCode: result.StatusCode);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user