- 后端新增管理员、商品、分类聚合模型 - 实现积分规则、礼品、订单、会员等完整功能 - 添加管理员认证和权限管理 - 完善数据库迁移和实体配置 - 前端管理后台实现登录、仪表盘、积分规则、礼品、订单、会员等页面 - 集成shadcn-vue UI组件库 - 添加前后端功能文档和截图
40 lines
1.2 KiB
C#
40 lines
1.2 KiB
C#
using FastEndpoints;
|
|
using Fengling.Backend.Domain.AggregatesModel.AdminAggregate;
|
|
using Fengling.Backend.Web.Application.Commands.AdminAuth;
|
|
|
|
namespace Fengling.Backend.Web.Endpoints.AdminAuth;
|
|
|
|
/// <summary>
|
|
/// 管理员登录请求
|
|
/// </summary>
|
|
public record AdminLoginRequest(string Username, string Password);
|
|
|
|
/// <summary>
|
|
/// 管理员登录响应
|
|
/// </summary>
|
|
public record AdminLoginResponseDto(AdminId AdminId, string Username, string Token, DateTime ExpiresAt);
|
|
|
|
/// <summary>
|
|
/// 管理员登录端点
|
|
/// </summary>
|
|
[Tags("AdminAuth")]
|
|
[HttpPost("/api/admin/auth/login")]
|
|
[AllowAnonymous]
|
|
public class AdminLoginEndpoint(IMediator mediator)
|
|
: Endpoint<AdminLoginRequest, ResponseData<AdminLoginResponseDto>>
|
|
{
|
|
public override async Task HandleAsync(AdminLoginRequest req, CancellationToken ct)
|
|
{
|
|
var command = new AdminLoginCommand(req.Username, req.Password);
|
|
var response = await mediator.Send(command, ct);
|
|
|
|
var dto = new AdminLoginResponseDto(
|
|
response.AdminId,
|
|
response.Username,
|
|
response.Token,
|
|
response.ExpiresAt);
|
|
|
|
await Send.OkAsync(dto.AsResponseData(), ct);
|
|
}
|
|
}
|