41 lines
1.4 KiB
C#
41 lines
1.4 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 OrderTaskRepository : OmsSqlSugarRepository<OrderTask>, IOrderTaskRepository, IScopedDependency
|
|
{
|
|
public Task<OrderTask?> GetByCustomerAndIdAsync(int customerId, int id, CancellationToken cancellationToken = default)
|
|
{
|
|
return FirstOrDefaultAsync(x => x.CustomerId == customerId && x.Id == id, cancellationToken);
|
|
}
|
|
|
|
public Task<bool> ExistsAsync(int id, CancellationToken cancellationToken = default)
|
|
{
|
|
return AnyAsync(x => x.Id == id, cancellationToken);
|
|
}
|
|
|
|
public async Task<List<OrderTaskFail>> GetFailListAsync(int taskId, CancellationToken cancellationToken = default)
|
|
{
|
|
var db = await GetDbContextAsync(cancellationToken);
|
|
return await db.Queryable<OrderTaskFail>()
|
|
.Where(x => x.TaskId == taskId)
|
|
.OrderBy(x => x.RowNumber)
|
|
.ToListAsync(cancellationToken);
|
|
}
|
|
|
|
public async Task InsertFailListAsync(IEnumerable<OrderTaskFail> failList, CancellationToken cancellationToken = default)
|
|
{
|
|
var items = failList.ToArray();
|
|
if (items.Length == 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var db = await GetDbContextAsync(cancellationToken);
|
|
await db.Insertable(items).ExecuteCommandAsync(cancellationToken);
|
|
}
|
|
}
|