fix: 允许平台账号跨租户更新门店

This commit is contained in:
2026-01-21 17:21:30 +08:00
parent 41ce8f2ccb
commit 187534ecca

View File

@@ -1,4 +1,5 @@
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using TakeoutSaaS.Application.App.Stores;
using TakeoutSaaS.Application.App.Stores.Commands;
@@ -18,6 +19,7 @@ namespace TakeoutSaaS.Application.App.Stores.Handlers;
public sealed class UpdateStoreCommandHandler(
IStoreRepository storeRepository,
ITenantProvider tenantProvider,
IHttpContextAccessor httpContextAccessor,
ILogger<UpdateStoreCommandHandler> logger)
: IRequestHandler<UpdateStoreCommand, StoreDto?>
{
@@ -25,7 +27,8 @@ public sealed class UpdateStoreCommandHandler(
public async Task<StoreDto?> Handle(UpdateStoreCommand request, CancellationToken cancellationToken)
{
// 1. 读取门店
var tenantId = tenantProvider.GetCurrentTenantId();
var ignoreTenantFilter = StoreTenantAccess.ShouldIgnoreTenantFilter(httpContextAccessor);
var tenantId = ignoreTenantFilter ? 0 : tenantProvider.GetCurrentTenantId();
var existing = await storeRepository.FindByIdAsync(request.StoreId, tenantId, cancellationToken);
if (existing == null)
{