57 lines
2.1 KiB
C#
57 lines
2.1 KiB
C#
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<Customs9610Order>, ICustoms9610OrderRepository, IScopedDependency
|
|
{
|
|
public Task<Customs9610Order?> 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<Customs9610OrderItem>()
|
|
.Where(x => x.Customs9610OrderId == customs9610OrderId)
|
|
.ExecuteCommandAsync(cancellationToken);
|
|
}
|
|
|
|
public async Task HardDeleteAsync(Customs9610Order entity, CancellationToken cancellationToken = default)
|
|
{
|
|
var db = await GetDbContextAsync(cancellationToken);
|
|
await db.Deleteable<Customs9610Order>()
|
|
.Where(x => x.Id == entity.Id)
|
|
.ExecuteCommandAsync(cancellationToken);
|
|
}
|
|
}
|
|
|
|
public class Customs9610OrderItemRepository
|
|
: OmsSqlSugarRepository<Customs9610OrderItem>,
|
|
ICustoms9610OrderItemRepository,
|
|
IScopedDependency
|
|
{
|
|
public Task<List<Customs9610OrderItem>> GetByHeaderIdAsync(
|
|
int customs9610OrderId,
|
|
CancellationToken cancellationToken = default)
|
|
{
|
|
return GetListAsync(x => x.Customs9610OrderId == customs9610OrderId, cancellationToken: cancellationToken);
|
|
}
|
|
|
|
public async Task<List<Customs9610OrderItem>> GetByHeaderIdsAsync(
|
|
IReadOnlyCollection<int> 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);
|
|
}
|
|
}
|