refactor: 移除门店跨租户访问入口

This commit is contained in:
root
2026-01-29 14:50:49 +00:00
parent 52fb4fde72
commit f9053356c2
25 changed files with 98 additions and 282 deletions

View File

@@ -1,5 +1,4 @@
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using TakeoutSaaS.Application.App.Stores;
using TakeoutSaaS.Application.App.Stores.Commands;
@@ -21,7 +20,6 @@ public sealed class CreateStoreCommandHandler(
IStoreRepository storeRepository,
IMerchantRepository merchantRepository,
ITenantProvider tenantProvider,
IHttpContextAccessor httpContextAccessor,
ILogger<CreateStoreCommandHandler> logger)
: IRequestHandler<CreateStoreCommand, StoreDto>
{
@@ -30,10 +28,7 @@ public sealed class CreateStoreCommandHandler(
{
// 1. 校验商户存在并解析租户
var currentTenantId = tenantProvider.GetCurrentTenantId();
var allowCrossTenant = StoreTenantAccess.ShouldIgnoreTenantFilter(httpContextAccessor);
var merchant = allowCrossTenant
? await merchantRepository.FindByIdAsync(request.MerchantId, cancellationToken)
: await merchantRepository.FindByIdAsync(request.MerchantId, currentTenantId, cancellationToken);
var merchant = await merchantRepository.FindByIdAsync(request.MerchantId, currentTenantId, cancellationToken);
if (merchant == null)
{
throw new BusinessException(ErrorCodes.NotFound, "商户不存在");