chore: update store delivery zone handlers

This commit is contained in:
2026-01-21 11:27:13 +08:00
parent 8bde1a6440
commit 36abd83e83
6 changed files with 60 additions and 10 deletions

View File

@@ -329,8 +329,19 @@ public sealed class EfStoreRepository(TakeoutAppDbContext context) : IStoreRepos
/// <inheritdoc />
public Task<StoreDeliveryZone?> FindDeliveryZoneByIdAsync(long deliveryZoneId, long tenantId, CancellationToken cancellationToken = default)
{
return context.StoreDeliveryZones
.Where(x => x.TenantId == tenantId && x.Id == deliveryZoneId)
var query = context.StoreDeliveryZones.AsQueryable();
if (tenantId <= 0)
{
query = query.IgnoreQueryFilters()
.Where(x => x.DeletedAt == null);
}
else
{
query = query.Where(x => x.TenantId == tenantId);
}
return query
.Where(x => x.Id == deliveryZoneId)
.FirstOrDefaultAsync(cancellationToken);
}
@@ -615,8 +626,19 @@ public sealed class EfStoreRepository(TakeoutAppDbContext context) : IStoreRepos
/// <inheritdoc />
public async Task DeleteDeliveryZoneAsync(long deliveryZoneId, long tenantId, CancellationToken cancellationToken = default)
{
var existing = await context.StoreDeliveryZones
.Where(x => x.TenantId == tenantId && x.Id == deliveryZoneId)
var query = context.StoreDeliveryZones.AsQueryable();
if (tenantId <= 0)
{
query = query.IgnoreQueryFilters()
.Where(x => x.DeletedAt == null);
}
else
{
query = query.Where(x => x.TenantId == tenantId);
}
var existing = await query
.Where(x => x.Id == deliveryZoneId)
.FirstOrDefaultAsync(cancellationToken);
if (existing != null)