From 1a5209a8b1df2d10d4dc2ea8bf1ccfe19b61db39 Mon Sep 17 00:00:00 2001
From: MSuMshk <2039814060@qq.com>
Date: Thu, 4 Dec 2025 09:10:00 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E6=A1=8C=E7=A0=81=E7=AE=A1=E7=90=86?=
=?UTF-8?q?=E6=94=AF=E6=8C=81=E5=8C=BA=E5=9F=9F=E3=80=81=E6=89=B9=E9=87=8F?=
=?UTF-8?q?=E7=94=9F=E6=88=90=E4=B8=8E=E4=BA=8C=E7=BB=B4=E7=A0=81=E5=AF=BC?=
=?UTF-8?q?=E5=87=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Document/12_BusinessTodo.md | 4 +-
.../Controllers/StoreTableAreasController.cs | 87 +++++++++++++
.../Controllers/StoreTablesController.cs | 121 ++++++++++++++++++
.../appsettings.Seed.Development.json | 28 ++++
.../Commands/CreateStoreTableAreaCommand.cs | 30 +++++
.../Commands/DeleteStoreTableAreaCommand.cs | 19 +++
.../Commands/DeleteStoreTableCommand.cs | 19 +++
.../Commands/GenerateStoreTablesCommand.cs | 45 +++++++
.../Commands/UpdateStoreTableAreaCommand.cs | 35 +++++
.../Commands/UpdateStoreTableCommand.cs | 46 +++++++
.../App/Stores/Dto/StoreTableAreaDto.cs | 48 +++++++
.../App/Stores/Dto/StoreTableDto.cs | 65 ++++++++++
.../App/Stores/Dto/StoreTableExportResult.cs | 22 ++++
.../CreateStoreTableAreaCommandHandler.cs | 58 +++++++++
.../DeleteStoreTableAreaCommandHandler.cs | 52 ++++++++
.../DeleteStoreTableCommandHandler.cs | 36 ++++++
.../ExportStoreTableQRCodesQueryHandler.cs | 86 +++++++++++++
.../GenerateStoreTablesCommandHandler.cs | 73 +++++++++++
.../ListStoreTableAreasQueryHandler.cs | 26 ++++
.../Handlers/ListStoreTablesQueryHandler.cs | 39 ++++++
.../UpdateStoreTableAreaCommandHandler.cs | 59 +++++++++
.../UpdateStoreTableCommandHandler.cs | 72 +++++++++++
.../Queries/ExportStoreTableQRCodesQuery.cs | 25 ++++
.../Queries/ListStoreTableAreasQuery.cs | 15 +++
.../Stores/Queries/ListStoreTablesQuery.cs | 26 ++++
.../App/Stores/StoreMapping.cs | 35 +++++
.../CreateStoreTableAreaCommandValidator.cs | 21 +++
.../GenerateStoreTablesCommandValidator.cs | 23 ++++
.../UpdateStoreTableAreaCommandValidator.cs | 22 ++++
.../UpdateStoreTableCommandValidator.cs | 22 ++++
.../TakeoutSaaS.Application.csproj | Bin 2662 -> 2782 bytes
.../Stores/Repositories/IStoreRepository.cs | 30 +++++
.../App/Repositories/EfStoreRepository.cs | 56 ++++++++
33 files changed, 1343 insertions(+), 2 deletions(-)
create mode 100644 src/Api/TakeoutSaaS.AdminApi/Controllers/StoreTableAreasController.cs
create mode 100644 src/Api/TakeoutSaaS.AdminApi/Controllers/StoreTablesController.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Commands/CreateStoreTableAreaCommand.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Commands/DeleteStoreTableAreaCommand.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Commands/DeleteStoreTableCommand.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Commands/GenerateStoreTablesCommand.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Commands/UpdateStoreTableAreaCommand.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Commands/UpdateStoreTableCommand.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Dto/StoreTableAreaDto.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Dto/StoreTableDto.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Dto/StoreTableExportResult.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Handlers/CreateStoreTableAreaCommandHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Handlers/DeleteStoreTableAreaCommandHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Handlers/DeleteStoreTableCommandHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Handlers/ExportStoreTableQRCodesQueryHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Handlers/GenerateStoreTablesCommandHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Handlers/ListStoreTableAreasQueryHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Handlers/ListStoreTablesQueryHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Handlers/UpdateStoreTableAreaCommandHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Handlers/UpdateStoreTableCommandHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Queries/ExportStoreTableQRCodesQuery.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Queries/ListStoreTableAreasQuery.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Queries/ListStoreTablesQuery.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Validators/CreateStoreTableAreaCommandValidator.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Validators/GenerateStoreTablesCommandValidator.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Validators/UpdateStoreTableAreaCommandValidator.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Validators/UpdateStoreTableCommandValidator.cs
diff --git a/Document/12_BusinessTodo.md b/Document/12_BusinessTodo.md
index 0d2cad0..44e9773 100644
--- a/Document/12_BusinessTodo.md
+++ b/Document/12_BusinessTodo.md
@@ -16,8 +16,8 @@
- 已交付:新增账单/公告/通知实体与仓储,Admin 端提供 `/tenants/{id}/billings`(列表/详情/创建/标记支付)、`/announcements`(列表/详情/创建/更新/删除/已读)、`/notifications`(列表/已读)端点;权限码补充 `tenant-bill:*`、`tenant-announcement:*`、`tenant-notification:*`,种子模板更新;配额/订阅告警可通过通知表承载。
- [x] 门店管理:Store/StoreBusinessHour/StoreDeliveryZone/StoreHoliday CRUD 完整,含 GeoJSON 配送范围及能力开关。
- 进展:已补充营业时间/配送区/节假日的命令、查询、验证与处理器,Admin API 新增子路由完成 CRUD,门店能力开关(预约/排队)已对外暴露;仓储扩展读写删除并保持租户过滤。
-- [ ] 桌码管理:批量生成桌码、绑定区域/容量、导出二维码 ZIP(POST /api/admin/stores/{id}/tables 可下载)。
- - 当前:模型/仓储已包含 `StoreTable`/`StoreTableArea`,但缺少命令/查询/控制器,未实现批量生成、区域容量绑定和二维码导出。
+- [x] 桌码管理:批量生成桌码、绑定区域/容量、导出二维码 ZIP(POST /api/admin/stores/{id}/tables 可下载)。
+ - 进展:新增桌台区域/桌码 DTO、命令、查询、验证与处理器,支持批量生成桌码、区域绑定和更新;Admin API 增加桌台区域与桌码 CRUD 及二维码 ZIP 导出端点,使用 QRCoder 生成 SVG 并打包下载;仓储补齐桌台/区域的查找、更新、删除。
- [ ] 员工排班:创建员工、绑定门店角色、维护 StoreEmployeeShift,可查询未来 7 日排班。
- 当前:存在 `StoreEmployeeShift` 表模型,未提供应用层命令/查询和 Admin API,排班创建/查询能力缺失。
- [ ] 桌码扫码入口:Mini 端解析二维码,GET /api/mini/tables/{code}/context 返回门店、桌台、公告。
diff --git a/src/Api/TakeoutSaaS.AdminApi/Controllers/StoreTableAreasController.cs b/src/Api/TakeoutSaaS.AdminApi/Controllers/StoreTableAreasController.cs
new file mode 100644
index 0000000..26275da
--- /dev/null
+++ b/src/Api/TakeoutSaaS.AdminApi/Controllers/StoreTableAreasController.cs
@@ -0,0 +1,87 @@
+using System.Collections.Generic;
+using MediatR;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using TakeoutSaaS.Application.App.Stores.Commands;
+using TakeoutSaaS.Application.App.Stores.Dto;
+using TakeoutSaaS.Application.App.Stores.Queries;
+using TakeoutSaaS.Module.Authorization.Attributes;
+using TakeoutSaaS.Shared.Abstractions.Constants;
+using TakeoutSaaS.Shared.Abstractions.Results;
+using TakeoutSaaS.Shared.Web.Api;
+
+namespace TakeoutSaaS.AdminApi.Controllers;
+
+///
+/// 门店桌台区域管理。
+///
+[ApiVersion("1.0")]
+[Authorize]
+[Route("api/admin/v{version:apiVersion}/stores/{storeId:long}/table-areas")]
+public sealed class StoreTableAreasController(IMediator mediator) : BaseApiController
+{
+ ///
+ /// 查询区域列表。
+ ///
+ [HttpGet]
+ [PermissionAuthorize("store-table-area:read")]
+ [ProducesResponseType(typeof(ApiResponse>), StatusCodes.Status200OK)]
+ public async Task>> List(long storeId, CancellationToken cancellationToken)
+ {
+ var result = await mediator.Send(new ListStoreTableAreasQuery { StoreId = storeId }, cancellationToken);
+ return ApiResponse>.Ok(result);
+ }
+
+ ///
+ /// 创建区域。
+ ///
+ [HttpPost]
+ [PermissionAuthorize("store-table-area:create")]
+ [ProducesResponseType(typeof(ApiResponse), StatusCodes.Status200OK)]
+ public async Task> Create(long storeId, [FromBody] CreateStoreTableAreaCommand command, CancellationToken cancellationToken)
+ {
+ if (command.StoreId == 0)
+ {
+ command = command with { StoreId = storeId };
+ }
+
+ var result = await mediator.Send(command, cancellationToken);
+ return ApiResponse.Ok(result);
+ }
+
+ ///
+ /// 更新区域。
+ ///
+ [HttpPut("{areaId:long}")]
+ [PermissionAuthorize("store-table-area:update")]
+ [ProducesResponseType(typeof(ApiResponse), StatusCodes.Status200OK)]
+ [ProducesResponseType(typeof(ApiResponse