diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..6c8b717
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,13 @@
+# EditorConfig
+root = true
+
+[*.cs]
+dotnet_diagnostic.SA1600.severity = error
+dotnet_diagnostic.SA1601.severity = error
+dotnet_diagnostic.SA1615.severity = error
+dotnet_diagnostic.SA1629.severity = none
+dotnet_diagnostic.SA1202.severity = none
+dotnet_diagnostic.SA1200.severity = none
+dotnet_diagnostic.SA1623.severity = none
+dotnet_diagnostic.SA1111.severity = none
+dotnet_diagnostic.SA1101.severity = none
diff --git a/.gitignore b/.gitignore
index 3857e65..16baddd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,4 @@ bin/
obj/
**/bin/
**/obj/
+.claude/
diff --git a/Directory.Build.props b/Directory.Build.props
index 59c4f40..e975914 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -6,5 +6,7 @@
latest
false
+
+
+
-
diff --git a/src/Api/TakeoutSaaS.AdminApi/Controllers/AuthController.cs b/src/Api/TakeoutSaaS.AdminApi/Controllers/AuthController.cs
index 72f23f4..32b4e5a 100644
--- a/src/Api/TakeoutSaaS.AdminApi/Controllers/AuthController.cs
+++ b/src/Api/TakeoutSaaS.AdminApi/Controllers/AuthController.cs
@@ -1,8 +1,4 @@
-using System;
-using System.Threading;
-using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using TakeoutSaaS.Application.Identity.Abstractions;
using TakeoutSaaS.Application.Identity.Contracts;
@@ -13,24 +9,22 @@ using TakeoutSaaS.Shared.Web.Api;
using TakeoutSaaS.Shared.Web.Security;
namespace TakeoutSaaS.AdminApi.Controllers;
-
///
/// 管理后台认证接口
///
-///
-///
-///
-///
+/// 提供登录、刷新 Token 以及用户权限查询能力。
+/// 认证服务
[ApiVersion("1.0")]
[Authorize]
[Route("api/admin/v{version:apiVersion}/auth")]
public sealed class AuthController(IAdminAuthService authService) : BaseApiController
{
-
-
///
/// 登录获取 Token
///
+ /// 登录请求。
+ /// 取消标记。
+ /// 包含访问令牌与刷新令牌的响应。
[HttpPost("login")]
[AllowAnonymous]
[ProducesResponseType(typeof(ApiResponse), StatusCodes.Status200OK)]
@@ -43,6 +37,9 @@ public sealed class AuthController(IAdminAuthService authService) : BaseApiContr
///
/// 刷新 Token
///
+ /// 刷新令牌请求。
+ /// 取消标记。
+ /// 新的访问令牌与刷新令牌。
[HttpPost("refresh")]
[AllowAnonymous]
[ProducesResponseType(typeof(ApiResponse), StatusCodes.Status200OK)]
@@ -78,18 +75,22 @@ public sealed class AuthController(IAdminAuthService authService) : BaseApiContr
/// }
///
///
+ /// 取消标记。
+ /// 当前用户档案信息。
[HttpGet("profile")]
[PermissionAuthorize("identity:profile:read")]
[ProducesResponseType(typeof(ApiResponse), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ApiResponse), StatusCodes.Status401Unauthorized)]
public async Task> GetProfile(CancellationToken cancellationToken)
{
+ // 1. 从 JWT 中获取当前用户标识
var userId = User.GetUserId();
if (userId == 0)
{
return ApiResponse.Error(ErrorCodes.Unauthorized, "Token 缺少有效的用户标识");
}
+ // 2. 读取用户档案并返回
var profile = await authService.GetProfileAsync(userId, cancellationToken);
return ApiResponse.Ok(profile);
}
@@ -119,6 +120,9 @@ public sealed class AuthController(IAdminAuthService authService) : BaseApiContr
/// }
///
///
+ /// 目标用户 ID。
+ /// 取消标记。
+ /// 用户权限概览,未找到则返回 404。
[HttpGet("permissions/{userId:long}")]
[PermissionAuthorize("identity:permission:read")]
[ProducesResponseType(typeof(ApiResponse), StatusCodes.Status200OK)]
diff --git a/src/Api/TakeoutSaaS.AdminApi/Controllers/DeliveriesController.cs b/src/Api/TakeoutSaaS.AdminApi/Controllers/DeliveriesController.cs
index fe5d2cf..6f0f953 100644
--- a/src/Api/TakeoutSaaS.AdminApi/Controllers/DeliveriesController.cs
+++ b/src/Api/TakeoutSaaS.AdminApi/Controllers/DeliveriesController.cs
@@ -1,6 +1,5 @@
using MediatR;
using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using TakeoutSaaS.Application.App.Deliveries.Commands;
using TakeoutSaaS.Application.App.Deliveries.Dto;
@@ -16,31 +15,40 @@ namespace TakeoutSaaS.AdminApi.Controllers;
///
/// 配送单管理。
///
-///
-/// 初始化控制器。
-///
[ApiVersion("1.0")]
[Authorize]
[Route("api/admin/v{version:apiVersion}/deliveries")]
public sealed class DeliveriesController(IMediator mediator) : BaseApiController
{
-
-
///
/// 创建配送单。
///
+ /// 创建命令。
+ /// 取消标记。
+ /// 创建后的配送单。
[HttpPost]
[PermissionAuthorize("delivery:create")]
[ProducesResponseType(typeof(ApiResponse), StatusCodes.Status200OK)]
public async Task> Create([FromBody] CreateDeliveryOrderCommand command, CancellationToken cancellationToken)
{
+ // 1. 创建配送单
var result = await mediator.Send(command, cancellationToken);
+
+ // 2. 返回创建结果
return ApiResponse.Ok(result);
}
///
/// 查询配送单列表。
///
+ /// 订单 ID。
+ /// 配送状态。
+ /// 页码。
+ /// 每页大小。
+ /// 排序字段。
+ /// 是否倒序。
+ /// 取消标记。
+ /// 配送单分页列表。
[HttpGet]
[PermissionAuthorize("delivery:read")]
[ProducesResponseType(typeof(ApiResponse>), StatusCodes.Status200OK)]
@@ -53,6 +61,7 @@ public sealed class DeliveriesController(IMediator mediator) : BaseApiController
[FromQuery] bool sortDesc = true,
CancellationToken cancellationToken = default)
{
+ // 1. 组装查询参数
var result = await mediator.Send(new SearchDeliveryOrdersQuery
{
OrderId = orderId,
@@ -63,19 +72,26 @@ public sealed class DeliveriesController(IMediator mediator) : BaseApiController
SortDescending = sortDesc
}, cancellationToken);
+ // 2. 返回分页结果
return ApiResponse>.Ok(result);
}
///
/// 获取配送单详情。
///
+ /// 配送单 ID。
+ /// 取消标记。
+ /// 配送单详情或未找到。
[HttpGet("{deliveryOrderId:long}")]
[PermissionAuthorize("delivery:read")]
[ProducesResponseType(typeof(ApiResponse), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ApiResponse