feat: 增强仓储CRUD与种子配置

This commit is contained in:
2025-12-02 09:46:44 +08:00
parent ffc4f0885f
commit 1a01454266
16 changed files with 587 additions and 56 deletions

View File

@@ -68,4 +68,35 @@ public sealed class EfDeliveryRepository : IDeliveryRepository
{
return _context.SaveChangesAsync(cancellationToken);
}
/// <inheritdoc />
public Task UpdateDeliveryOrderAsync(DeliveryOrder deliveryOrder, CancellationToken cancellationToken = default)
{
_context.DeliveryOrders.Update(deliveryOrder);
return Task.CompletedTask;
}
/// <inheritdoc />
public async Task DeleteDeliveryOrderAsync(long deliveryOrderId, long tenantId, CancellationToken cancellationToken = default)
{
var events = await _context.DeliveryEvents
.Where(x => x.TenantId == tenantId && x.DeliveryOrderId == deliveryOrderId)
.ToListAsync(cancellationToken);
if (events.Count > 0)
{
_context.DeliveryEvents.RemoveRange(events);
}
var existing = await _context.DeliveryOrders
.Where(x => x.TenantId == tenantId && x.Id == deliveryOrderId)
.FirstOrDefaultAsync(cancellationToken);
if (existing == null)
{
return;
}
_context.DeliveryOrders.Remove(existing);
}
}