From 5cdc7052e014813733973c379d92d63010d5f302 Mon Sep 17 00:00:00 2001
From: luoqian <2769838458@qq.com>
Date: Fri, 22 May 2026 11:42:38 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=8C=E5=96=84=E7=BB=9F=E4=B8=80?=
=?UTF-8?q?=E7=AB=AF=E7=82=B9=E5=93=8D=E5=BA=94=E4=B8=8E=E8=AF=B7=E6=B1=82?=
=?UTF-8?q?=E7=BB=91=E5=AE=9A=E6=A1=86=E6=9E=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 新增 IApiResponse 统一响应契约,覆盖普通响应和分页响应
- 扩展端点映射,支持 IApiResponse 和带请求 DTO 的 MapXxx 重载
- 增加 Body、Query、Route Values 到请求 DTO 的自动绑定
- 增加 PC 端路由模式匹配,支持 {id} 和 {id:int}
- API 与 PC 端点上下文补充路由参数传递
- 调整 OpenAPI 请求类型处理,避免 GET/DELETE 被标记为 JSON Body
- 鉴权端点迁移到强类型请求绑定和 IApiResponse 返回
- 增加统一端点文件流响应支持
---
.../Authentication/ApiAuthEndpointService.cs | 34 +---
.../Extensions/UnifiedEndpointExtensions.cs | 37 +++-
Avalonia-Common/Core/ApiResponse.cs | 16 +-
.../Authentication/PcAuthEndpointService.cs | 36 +---
Avalonia-Services/Core/FileStreamResponse.cs | 11 ++
.../Core/ServiceEndpointCollection.cs | 168 ++++++++++++++++++
.../Core/ServiceEndpointContext.cs | 5 +
.../Core/ServiceEndpointPatternMatcher.cs | 75 ++++++++
.../Core/ServiceRequestBinder.cs | 53 ++++++
Avalonia-Services/Endpoints/AppEndpoints.cs | 6 +-
Avalonia-Services/Endpoints/AuthEndpoints.cs | 24 ++-
.../Extensions/DesktopEndpointAdapter.cs | 18 +-
.../AuthService/AuthEndpointServices.cs | 13 +-
13 files changed, 414 insertions(+), 82 deletions(-)
create mode 100644 Avalonia-Services/Core/FileStreamResponse.cs
create mode 100644 Avalonia-Services/Core/ServiceEndpointPatternMatcher.cs
create mode 100644 Avalonia-Services/Core/ServiceRequestBinder.cs
diff --git a/Avalonia-API/Authentication/ApiAuthEndpointService.cs b/Avalonia-API/Authentication/ApiAuthEndpointService.cs
index 8c97530..ce714aa 100644
--- a/Avalonia-API/Authentication/ApiAuthEndpointService.cs
+++ b/Avalonia-API/Authentication/ApiAuthEndpointService.cs
@@ -4,7 +4,6 @@ using Avalonia_EFCore.Models;
using Avalonia_Services.Core;
using Avalonia_Services.Services.AuthService;
using Microsoft.EntityFrameworkCore;
-using System.Text.Json;
namespace Avalonia_API.Authentication
{
@@ -17,21 +16,15 @@ namespace Avalonia_API.Authentication
JwtTokenService jwtTokenService,
RefreshTokenService refreshTokenService) : IApiAuthEndpointService
{
- private static readonly JsonSerializerOptions JsonOptions = new()
- {
- PropertyNameCaseInsensitive = true,
- };
-
///
/// 处理用户登录请求。根据账号(邮箱或用户名)查找或创建用户,
/// 生成 JWT Access Token 和 Refresh Token 并返回。
///
/// 服务端点上下文,包含请求体、请求头等信息。
/// 包含 AccessToken、RefreshToken 及过期时间的认证响应。
- public async Task