From 19422df0f1401092d306f80b961de218694d17f0 Mon Sep 17 00:00:00 2001
From: MSuMshk <2039814060@qq.com>
Date: Thu, 4 Dec 2025 09:32:03 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E9=97=A8=E5=BA=97=E5=91=98=E5=B7=A5?=
=?UTF-8?q?=E4=B8=8E=E6=8E=92=E7=8F=AD=E7=AE=A1=E7=90=86=E4=B8=8A=E7=BA=BF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Document/12_BusinessTodo.md | 4 +-
.../Controllers/StoreShiftsController.cs | 99 +++++++++++++++++++
.../Controllers/StoreStaffsController.cs | 98 ++++++++++++++++++
.../appsettings.Seed.Development.json | 23 +++++
.../CreateStoreEmployeeShiftCommand.cs | 46 +++++++++
.../Commands/CreateStoreStaffCommand.cs | 36 +++++++
.../DeleteStoreEmployeeShiftCommand.cs | 19 ++++
.../Commands/DeleteStoreStaffCommand.cs | 19 ++++
.../UpdateStoreEmployeeShiftCommand.cs | 51 ++++++++++
.../Commands/UpdateStoreStaffCommand.cs | 46 +++++++++
.../App/Stores/Dto/StoreEmployeeShiftDto.cs | 65 ++++++++++++
.../App/Stores/Dto/StoreStaffDto.cs | 60 +++++++++++
.../CreateStoreEmployeeShiftCommandHandler.cs | 72 ++++++++++++++
.../CreateStoreStaffCommandHandler.cs | 56 +++++++++++
.../DeleteStoreEmployeeShiftCommandHandler.cs | 36 +++++++
.../DeleteStoreStaffCommandHandler.cs | 35 +++++++
.../ListStoreEmployeeShiftsQueryHandler.cs | 37 +++++++
.../Handlers/ListStoreStaffQueryHandler.cs | 47 +++++++++
.../UpdateStoreEmployeeShiftCommandHandler.cs | 71 +++++++++++++
.../UpdateStoreStaffCommandHandler.cs | 55 +++++++++++
.../Queries/ListStoreEmployeeShiftsQuery.cs | 30 ++++++
.../App/Stores/Queries/ListStoreStaffQuery.cs | 26 +++++
.../App/Stores/StoreMapping.cs | 38 +++++++
...reateStoreEmployeeShiftCommandValidator.cs | 22 +++++
.../CreateStoreStaffCommandValidator.cs | 21 ++++
...pdateStoreEmployeeShiftCommandValidator.cs | 23 +++++
.../UpdateStoreStaffCommandValidator.cs | 22 +++++
.../Repositories/IMerchantRepository.cs | 15 +++
.../Stores/Repositories/IStoreRepository.cs | 19 +++-
.../App/Repositories/EfMerchantRepository.cs | 35 +++++++
.../App/Repositories/EfStoreRepository.cs | 46 ++++++++-
31 files changed, 1265 insertions(+), 7 deletions(-)
create mode 100644 src/Api/TakeoutSaaS.AdminApi/Controllers/StoreShiftsController.cs
create mode 100644 src/Api/TakeoutSaaS.AdminApi/Controllers/StoreStaffsController.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Commands/CreateStoreEmployeeShiftCommand.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Commands/CreateStoreStaffCommand.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Commands/DeleteStoreEmployeeShiftCommand.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Commands/DeleteStoreStaffCommand.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Commands/UpdateStoreEmployeeShiftCommand.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Commands/UpdateStoreStaffCommand.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Dto/StoreEmployeeShiftDto.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Dto/StoreStaffDto.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Handlers/CreateStoreEmployeeShiftCommandHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Handlers/CreateStoreStaffCommandHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Handlers/DeleteStoreEmployeeShiftCommandHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Handlers/DeleteStoreStaffCommandHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Handlers/ListStoreEmployeeShiftsQueryHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Handlers/ListStoreStaffQueryHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Handlers/UpdateStoreEmployeeShiftCommandHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Handlers/UpdateStoreStaffCommandHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Queries/ListStoreEmployeeShiftsQuery.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Queries/ListStoreStaffQuery.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Validators/CreateStoreEmployeeShiftCommandValidator.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Validators/CreateStoreStaffCommandValidator.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Validators/UpdateStoreEmployeeShiftCommandValidator.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Validators/UpdateStoreStaffCommandValidator.cs
diff --git a/Document/12_BusinessTodo.md b/Document/12_BusinessTodo.md
index 44e9773..870b3e7 100644
--- a/Document/12_BusinessTodo.md
+++ b/Document/12_BusinessTodo.md
@@ -18,8 +18,8 @@
- 进展:已补充营业时间/配送区/节假日的命令、查询、验证与处理器,Admin API 新增子路由完成 CRUD,门店能力开关(预约/排队)已对外暴露;仓储扩展读写删除并保持租户过滤。
- [x] 桌码管理:批量生成桌码、绑定区域/容量、导出二维码 ZIP(POST /api/admin/stores/{id}/tables 可下载)。
- 进展:新增桌台区域/桌码 DTO、命令、查询、验证与处理器,支持批量生成桌码、区域绑定和更新;Admin API 增加桌台区域与桌码 CRUD 及二维码 ZIP 导出端点,使用 QRCoder 生成 SVG 并打包下载;仓储补齐桌台/区域的查找、更新、删除。
-- [ ] 员工排班:创建员工、绑定门店角色、维护 StoreEmployeeShift,可查询未来 7 日排班。
- - 当前:存在 `StoreEmployeeShift` 表模型,未提供应用层命令/查询和 Admin API,排班创建/查询能力缺失。
+- [x] 员工排班:创建员工、绑定门店角色、维护 StoreEmployeeShift,可查询未来 7 日排班。
+ - 进展:新增门店员工 DTO/命令/查询/验证与处理器,支持员工创建/更新/删除及按门店查询;新增排班 CRUD(默认查询未来 7 天),校验员工归属、时间冲突;Admin API 增加员工与排班控制器及权限种子,仓储补充排班查询/更新/删除。
- [ ] 桌码扫码入口:Mini 端解析二维码,GET /api/mini/tables/{code}/context 返回门店、桌台、公告。
- 当前:MiniApi 无桌码相关接口,未实现桌码解析与上下文返回。
- [ ] 菜品建模:分类、SPU、SKU、规格/加料组、价格策略、媒资 CRUD + 上下架流程;Mini 端可拉取完整 JSON。
diff --git a/src/Api/TakeoutSaaS.AdminApi/Controllers/StoreShiftsController.cs b/src/Api/TakeoutSaaS.AdminApi/Controllers/StoreShiftsController.cs
new file mode 100644
index 0000000..4b6fa2d
--- /dev/null
+++ b/src/Api/TakeoutSaaS.AdminApi/Controllers/StoreShiftsController.cs
@@ -0,0 +1,99 @@
+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}/shifts")]
+public sealed class StoreShiftsController(IMediator mediator) : BaseApiController
+{
+ ///
+ /// 查询排班(默认未来 7 天)。
+ ///
+ [HttpGet]
+ [PermissionAuthorize("store-shift:read")]
+ [ProducesResponseType(typeof(ApiResponse>), StatusCodes.Status200OK)]
+ public async Task>> List(
+ long storeId,
+ [FromQuery] DateTime? from,
+ [FromQuery] DateTime? to,
+ [FromQuery] long? staffId,
+ CancellationToken cancellationToken)
+ {
+ var result = await mediator.Send(new ListStoreEmployeeShiftsQuery
+ {
+ StoreId = storeId,
+ From = from,
+ To = to,
+ StaffId = staffId
+ }, cancellationToken);
+
+ return ApiResponse>.Ok(result);
+ }
+
+ ///
+ /// 创建排班。
+ ///
+ [HttpPost]
+ [PermissionAuthorize("store-shift:create")]
+ [ProducesResponseType(typeof(ApiResponse), StatusCodes.Status200OK)]
+ public async Task> Create(long storeId, [FromBody] CreateStoreEmployeeShiftCommand command, CancellationToken cancellationToken)
+ {
+ if (command.StoreId == 0)
+ {
+ command = command with { StoreId = storeId };
+ }
+
+ var result = await mediator.Send(command, cancellationToken);
+ return ApiResponse.Ok(result);
+ }
+
+ ///
+ /// 更新排班。
+ ///
+ [HttpPut("{shiftId:long}")]
+ [PermissionAuthorize("store-shift:update")]
+ [ProducesResponseType(typeof(ApiResponse), StatusCodes.Status200OK)]
+ [ProducesResponseType(typeof(ApiResponse