feat: 完成门店子资源管理与文档同步

This commit is contained in:
2025-12-04 08:38:31 +08:00
parent 17d143a351
commit 9051a024ea
45 changed files with 1671 additions and 3 deletions

View File

@@ -58,6 +58,14 @@ public sealed class EfStoreRepository(TakeoutAppDbContext context) : IStoreRepos
return hours;
}
/// <inheritdoc />
public Task<StoreBusinessHour?> FindBusinessHourByIdAsync(long businessHourId, long tenantId, CancellationToken cancellationToken = default)
{
return context.StoreBusinessHours
.Where(x => x.TenantId == tenantId && x.Id == businessHourId)
.FirstOrDefaultAsync(cancellationToken);
}
/// <inheritdoc />
public async Task<IReadOnlyList<StoreDeliveryZone>> GetDeliveryZonesAsync(long storeId, long tenantId, CancellationToken cancellationToken = default)
{
@@ -70,6 +78,14 @@ public sealed class EfStoreRepository(TakeoutAppDbContext context) : IStoreRepos
return zones;
}
/// <inheritdoc />
public Task<StoreDeliveryZone?> FindDeliveryZoneByIdAsync(long deliveryZoneId, long tenantId, CancellationToken cancellationToken = default)
{
return context.StoreDeliveryZones
.Where(x => x.TenantId == tenantId && x.Id == deliveryZoneId)
.FirstOrDefaultAsync(cancellationToken);
}
/// <inheritdoc />
public async Task<IReadOnlyList<StoreHoliday>> GetHolidaysAsync(long storeId, long tenantId, CancellationToken cancellationToken = default)
{
@@ -82,6 +98,14 @@ public sealed class EfStoreRepository(TakeoutAppDbContext context) : IStoreRepos
return holidays;
}
/// <inheritdoc />
public Task<StoreHoliday?> FindHolidayByIdAsync(long holidayId, long tenantId, CancellationToken cancellationToken = default)
{
return context.StoreHolidays
.Where(x => x.TenantId == tenantId && x.Id == holidayId)
.FirstOrDefaultAsync(cancellationToken);
}
/// <inheritdoc />
public async Task<IReadOnlyList<StoreTableArea>> GetTableAreasAsync(long storeId, long tenantId, CancellationToken cancellationToken = default)
{
@@ -131,18 +155,39 @@ public sealed class EfStoreRepository(TakeoutAppDbContext context) : IStoreRepos
return context.StoreBusinessHours.AddRangeAsync(hours, cancellationToken);
}
/// <inheritdoc />
public Task UpdateBusinessHourAsync(StoreBusinessHour hour, CancellationToken cancellationToken = default)
{
context.StoreBusinessHours.Update(hour);
return Task.CompletedTask;
}
/// <inheritdoc />
public Task AddDeliveryZonesAsync(IEnumerable<StoreDeliveryZone> zones, CancellationToken cancellationToken = default)
{
return context.StoreDeliveryZones.AddRangeAsync(zones, cancellationToken);
}
/// <inheritdoc />
public Task UpdateDeliveryZoneAsync(StoreDeliveryZone zone, CancellationToken cancellationToken = default)
{
context.StoreDeliveryZones.Update(zone);
return Task.CompletedTask;
}
/// <inheritdoc />
public Task AddHolidaysAsync(IEnumerable<StoreHoliday> holidays, CancellationToken cancellationToken = default)
{
return context.StoreHolidays.AddRangeAsync(holidays, cancellationToken);
}
/// <inheritdoc />
public Task UpdateHolidayAsync(StoreHoliday holiday, CancellationToken cancellationToken = default)
{
context.StoreHolidays.Update(holiday);
return Task.CompletedTask;
}
/// <inheritdoc />
public Task AddTableAreasAsync(IEnumerable<StoreTableArea> areas, CancellationToken cancellationToken = default)
{
@@ -167,6 +212,45 @@ public sealed class EfStoreRepository(TakeoutAppDbContext context) : IStoreRepos
return context.SaveChangesAsync(cancellationToken);
}
/// <inheritdoc />
public async Task DeleteBusinessHourAsync(long businessHourId, long tenantId, CancellationToken cancellationToken = default)
{
var existing = await context.StoreBusinessHours
.Where(x => x.TenantId == tenantId && x.Id == businessHourId)
.FirstOrDefaultAsync(cancellationToken);
if (existing != null)
{
context.StoreBusinessHours.Remove(existing);
}
}
/// <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)
.FirstOrDefaultAsync(cancellationToken);
if (existing != null)
{
context.StoreDeliveryZones.Remove(existing);
}
}
/// <inheritdoc />
public async Task DeleteHolidayAsync(long holidayId, long tenantId, CancellationToken cancellationToken = default)
{
var existing = await context.StoreHolidays
.Where(x => x.TenantId == tenantId && x.Id == holidayId)
.FirstOrDefaultAsync(cancellationToken);
if (existing != null)
{
context.StoreHolidays.Remove(existing);
}
}
/// <inheritdoc />
public Task UpdateStoreAsync(Store store, CancellationToken cancellationToken = default)
{