using Fake.DependencyInjection; using Oms.Domain.OrdersAggregate.Entities; using Oms.Domain.OrdersAggregate.Repositories; using Oms.SqlSugarCore.Repositories; namespace Oms.SqlSugarCore.Orders; public class Customs9610OrderRepository : OmsSqlSugarRepository, ICustoms9610OrderRepository, IScopedDependency { public Task GetByOrderIdAsync(int orderId, CancellationToken cancellationToken = default) { return FirstOrDefaultAsync(x => x.OrderId == orderId, cancellationToken); } public async Task HardDeleteItemsByHeaderIdAsync(int customs9610OrderId, CancellationToken cancellationToken = default) { var db = await GetDbContextAsync(cancellationToken); await db.Deleteable() .Where(x => x.Customs9610OrderId == customs9610OrderId) .ExecuteCommandAsync(cancellationToken); } public async Task HardDeleteAsync(Customs9610Order entity, CancellationToken cancellationToken = default) { var db = await GetDbContextAsync(cancellationToken); await db.Deleteable() .Where(x => x.Id == entity.Id) .ExecuteCommandAsync(cancellationToken); } } public class Customs9610OrderItemRepository : OmsSqlSugarRepository, ICustoms9610OrderItemRepository, IScopedDependency { public Task> GetByHeaderIdAsync( int customs9610OrderId, CancellationToken cancellationToken = default) { return GetListAsync(x => x.Customs9610OrderId == customs9610OrderId, cancellationToken: cancellationToken); } public async Task> GetByHeaderIdsAsync( IReadOnlyCollection headerIds, CancellationToken cancellationToken = default) { if (headerIds == null || headerIds.Count == 0) { return []; } var ids = headerIds.Distinct().ToList(); return await GetListAsync(x => ids.Contains(x.Customs9610OrderId), cancellationToken: cancellationToken); } }