GET /api/public/home
GET /api/public/notices/{id}
SQLite / MySQL 双数据库只读连接
.env 与现有数据库配置兼容
公告 HTML 安全清洗
学校、班级、考试、科目、报名及系统通知聚合
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
using Eis.Application.Public;
|
||||
|
||||
namespace Eis.Web.Public;
|
||||
|
||||
public static class PublicEndpoints
|
||||
{
|
||||
public static IEndpointRouteBuilder MapNativePublicEndpoints(this IEndpointRouteBuilder endpoints)
|
||||
{
|
||||
endpoints.MapGet("/api/public/home", async (
|
||||
HttpContext context,
|
||||
IPublicQueryService queries,
|
||||
CancellationToken cancellationToken) =>
|
||||
{
|
||||
context.Response.Headers["X-EIS-Implementation"] = "aspnet-core";
|
||||
return Results.Json(await queries.GetHomeAsync(cancellationToken));
|
||||
});
|
||||
|
||||
endpoints.MapGet("/api/public/notices/{id}", async (
|
||||
string id,
|
||||
HttpContext context,
|
||||
IPublicQueryService queries,
|
||||
CancellationToken cancellationToken) =>
|
||||
{
|
||||
context.Response.Headers["X-EIS-Implementation"] = "aspnet-core";
|
||||
var notice = await queries.GetNoticeAsync(id, cancellationToken);
|
||||
return notice is null
|
||||
? Results.Json(new { ok = false, message = "通知不存在或尚未发布" }, statusCode: StatusCodes.Status404NotFound)
|
||||
: Results.Json(new { ok = true, notice });
|
||||
});
|
||||
|
||||
return endpoints;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user