admin/src/Oms.SqlSugarCore/Orders/OrderFileRepository.cs
zzh 61d1502148
All checks were successful
Build and Deploy / deploy (push) Successful in 1m44s
feat: 新增 /order/print/batch 同步批量返回面单地址
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-12 18:56:41 +08:00

64 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 OrderFileRepository
: OmsSqlSugarRepository<OrderFile>,
IOrderFileRepository,
IScopedDependency
{
public Task<List<OrderFile>> GetByOrderIdAsync(int orderId, CancellationToken cancellationToken = default) =>
GetListAsync(
x => x.OrderId == orderId,
cancellationToken: cancellationToken);
public Task<OrderFile?> GetByOrderAndTypeAsync(
int orderId,
string fileType,
CancellationToken cancellationToken = default) =>
FirstOrDefaultAsync(
x => x.OrderId == orderId && x.FileType == fileType,
cancellationToken);
public Task<List<OrderFile>> GetByOrderAndTypeListAsync(
int orderId,
string fileType,
CancellationToken cancellationToken = default) =>
GetListAsync(
x => x.OrderId == orderId && x.FileType == fileType,
cancellationToken: cancellationToken);
public Task<List<OrderFile>> GetByOrderIdsAndTypeAsync(
IReadOnlyCollection<int> orderIds,
string fileType,
CancellationToken cancellationToken = default)
{
var ids = orderIds?.Where(x => x > 0).Distinct().ToList() ?? [];
if (ids.Count == 0)
{
return Task.FromResult(new List<OrderFile>());
}
return GetListAsync(
x => ids.Contains(x.OrderId) && x.FileType == fileType,
cancellationToken: cancellationToken);
}
public async Task SoftDeleteByOrderAndTypeAsync(
int orderId,
string fileType,
CancellationToken cancellationToken = default)
{
var list = await GetByOrderAndTypeListAsync(orderId, fileType, cancellationToken);
foreach (var item in list)
{
item.IsDeleted = true;
item.UpdateTime = DateTime.Now;
await UpdateAsync(item, cancellationToken);
}
}
}