From 654b1ae3f74f4c2125f8a976072fed2a804f3a42 Mon Sep 17 00:00:00 2001
From: MSuMshk <2039814060@qq.com>
Date: Tue, 17 Feb 2026 11:10:06 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20tenant=E9=97=A8=E5=BA=97=E7=AE=A1?=
=?UTF-8?q?=E7=90=86=E9=A6=96=E6=89=B9=E6=8E=A5=E5=8F=A3=E8=90=BD=E5=9C=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Controllers/StoreController.cs | 112 +++
src/Api/TakeoutSaaS.TenantApi/Program.cs | 16 +-
...pApplicationServiceCollectionExtensions.cs | 35 +
.../App/Stores/Commands/CreateStoreCommand.cs | 52 ++
.../App/Stores/Commands/DeleteStoreCommand.cs | 18 +
.../App/Stores/Commands/UpdateStoreCommand.cs | 60 ++
.../App/Stores/Dto/StoreListItemDto.cs | 69 ++
.../App/Stores/Dto/StoreListResultDto.cs | 28 +
.../App/Stores/Dto/StoreStatsDto.cs | 28 +
.../App/Stores/Enums/ServiceType.cs | 23 +
.../Handlers/CreateStoreCommandHandler.cs | 71 ++
.../Handlers/DeleteStoreCommandHandler.cs | 37 +
.../Handlers/GetStoreStatsQueryHandler.cs | 45 +
.../Handlers/SearchStoresQueryHandler.cs | 61 ++
.../Handlers/UpdateStoreCommandHandler.cs | 71 ++
.../App/Stores/Queries/GetStoreStatsQuery.cs | 10 +
.../App/Stores/Queries/SearchStoresQuery.cs | 43 +
.../Stores/Services/StoreContextService.cs | 60 ++
.../App/Stores/StoreListMapping.cs | 121 +++
.../Validators/CreateStoreCommandValidator.cs | 31 +
.../Validators/DeleteStoreCommandValidator.cs | 20 +
.../Validators/SearchStoresQueryValidator.cs | 24 +
.../Validators/UpdateStoreCommandValidator.cs | 32 +
.../Stores/Repositories/IStoreRepository.cs | 63 +-
.../AppServiceCollectionExtensions.cs | 57 ++
.../Persistence/TakeoutTenantAppDbContext.cs | 306 +++++++
.../App/Repositories/EfStoreRepository.cs | 801 ++++++++++++++++++
.../Common/Persistence/AppDbContext.cs | 211 +++++
.../ModelBuilderCommentExtensions.cs | 146 ++++
.../Extensions/JwtAuthenticationExtensions.cs | 54 ++
.../Identity/Options/JwtOptions.cs | 40 +
31 files changed, 2731 insertions(+), 14 deletions(-)
create mode 100644 src/Api/TakeoutSaaS.TenantApi/Controllers/StoreController.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Extensions/AppApplicationServiceCollectionExtensions.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Commands/CreateStoreCommand.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Commands/DeleteStoreCommand.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Commands/UpdateStoreCommand.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Dto/StoreListItemDto.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Dto/StoreListResultDto.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Dto/StoreStatsDto.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Enums/ServiceType.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Handlers/CreateStoreCommandHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Handlers/DeleteStoreCommandHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Handlers/GetStoreStatsQueryHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Handlers/SearchStoresQueryHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Handlers/UpdateStoreCommandHandler.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Queries/GetStoreStatsQuery.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Queries/SearchStoresQuery.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Services/StoreContextService.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/StoreListMapping.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Validators/CreateStoreCommandValidator.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Validators/DeleteStoreCommandValidator.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Validators/SearchStoresQueryValidator.cs
create mode 100644 src/Application/TakeoutSaaS.Application/App/Stores/Validators/UpdateStoreCommandValidator.cs
create mode 100644 src/Infrastructure/TakeoutSaaS.Infrastructure/App/Extensions/AppServiceCollectionExtensions.cs
create mode 100644 src/Infrastructure/TakeoutSaaS.Infrastructure/App/Persistence/TakeoutTenantAppDbContext.cs
create mode 100644 src/Infrastructure/TakeoutSaaS.Infrastructure/App/Repositories/EfStoreRepository.cs
create mode 100644 src/Infrastructure/TakeoutSaaS.Infrastructure/Common/Persistence/AppDbContext.cs
create mode 100644 src/Infrastructure/TakeoutSaaS.Infrastructure/Common/Persistence/ModelBuilderCommentExtensions.cs
create mode 100644 src/Infrastructure/TakeoutSaaS.Infrastructure/Identity/Extensions/JwtAuthenticationExtensions.cs
create mode 100644 src/Infrastructure/TakeoutSaaS.Infrastructure/Identity/Options/JwtOptions.cs
diff --git a/src/Api/TakeoutSaaS.TenantApi/Controllers/StoreController.cs b/src/Api/TakeoutSaaS.TenantApi/Controllers/StoreController.cs
new file mode 100644
index 0000000..976fb52
--- /dev/null
+++ b/src/Api/TakeoutSaaS.TenantApi/Controllers/StoreController.cs
@@ -0,0 +1,112 @@
+using MediatR;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using TakeoutSaaS.Application.App.Stores.Commands;
+using TakeoutSaaS.Application.App.Stores.Dto;
+using TakeoutSaaS.Application.App.Stores.Queries;
+using TakeoutSaaS.Shared.Abstractions.Results;
+using TakeoutSaaS.Shared.Web.Api;
+
+namespace TakeoutSaaS.TenantApi.Controllers;
+
+///
+/// 租户端门店管理。
+///
+[ApiVersion("1.0")]
+[Authorize]
+[Route("api/tenant/v{version:apiVersion}/store")]
+public sealed class StoreController(IMediator mediator) : BaseApiController
+{
+ ///
+ /// 查询门店列表。
+ ///
+ /// 查询参数。
+ /// 取消标记。
+ /// 分页列表。
+ [HttpGet("list")]
+ [ProducesResponseType(typeof(ApiResponse), StatusCodes.Status200OK)]
+ [ProducesResponseType(typeof(ApiResponse), StatusCodes.Status401Unauthorized)]
+ public async Task> List([FromQuery] SearchStoresQuery query, CancellationToken cancellationToken)
+ {
+ // 1. 查询门店分页
+ var result = await mediator.Send(query, cancellationToken);
+
+ // 2. 返回分页数据
+ return ApiResponse.Ok(result);
+ }
+
+ ///
+ /// 查询门店统计。
+ ///
+ /// 取消标记。
+ /// 统计结果。
+ [HttpGet("stats")]
+ [ProducesResponseType(typeof(ApiResponse), StatusCodes.Status200OK)]
+ [ProducesResponseType(typeof(ApiResponse), StatusCodes.Status401Unauthorized)]
+ public async Task> Stats(CancellationToken cancellationToken)
+ {
+ // 1. 查询门店统计
+ var result = await mediator.Send(new GetStoreStatsQuery(), cancellationToken);
+
+ // 2. 返回统计结果
+ return ApiResponse.Ok(result);
+ }
+
+ ///
+ /// 创建门店。
+ ///
+ /// 创建命令。
+ /// 取消标记。
+ /// 创建结果。
+ [HttpPost("create")]
+ [ProducesResponseType(typeof(ApiResponse