- 后端新增管理员、商品、分类聚合模型 - 实现积分规则、礼品、订单、会员等完整功能 - 添加管理员认证和权限管理 - 完善数据库迁移和实体配置 - 前端管理后台实现登录、仪表盘、积分规则、礼品、订单、会员等页面 - 集成shadcn-vue UI组件库 - 添加前后端功能文档和截图
41 lines
1.2 KiB
C#
41 lines
1.2 KiB
C#
using FastEndpoints;
|
|
using Fengling.Backend.Domain.AggregatesModel.AdminAggregate;
|
|
using Fengling.Backend.Web.Application.Queries.AdminAuth;
|
|
using System.Security.Claims;
|
|
|
|
namespace Fengling.Backend.Web.Endpoints.AdminAuth;
|
|
|
|
/// <summary>
|
|
/// 获取当前管理员端点
|
|
/// </summary>
|
|
[Tags("AdminAuth")]
|
|
// [HttpGet("/api/admin/auth/me")]
|
|
public class GetCurrentAdminEndpoint(IMediator mediator)
|
|
: EndpointWithoutRequest<ResponseData<AdminDto>>
|
|
{
|
|
public override void Configure()
|
|
{
|
|
Get("/api/admin/auth/me");
|
|
Tags("AdminAuth");
|
|
Description(x => x.WithTags("AdminAuth"));
|
|
}
|
|
|
|
public override async Task HandleAsync(CancellationToken ct)
|
|
{
|
|
// 从 JWT Claims 中提取 AdminId
|
|
var adminIdClaim = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
|
|
|
if (string.IsNullOrEmpty(adminIdClaim) || !Guid.TryParse(adminIdClaim, out var adminGuid))
|
|
{
|
|
await Send.UnauthorizedAsync(ct);
|
|
return;
|
|
}
|
|
|
|
var adminId = new AdminId(adminGuid);
|
|
var query = new GetCurrentAdminQuery(adminId);
|
|
var admin = await mediator.Send(query, ct);
|
|
|
|
await Send.OkAsync(admin.AsResponseData(), ct);
|
|
}
|
|
}
|