新增地址簿 CRUD、pickup/create、订单 orderSource 筛选;附带包裹商品图片上传接口。 Co-authored-by: Cursor <cursoragent@cursor.com>
33 lines
1.1 KiB
C#
33 lines
1.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 CustomerSenderAddressRepository : OmsSqlSugarRepository<CustomerSenderAddress>, ICustomerSenderAddressRepository, IScopedDependency
|
|
{
|
|
public Task<CustomerSenderAddress?> GetOwnedAsync(int id, int customerId, CancellationToken cancellationToken = default)
|
|
{
|
|
return FirstOrDefaultAsync(x => x.Id == id && x.CustomerId == customerId, cancellationToken);
|
|
}
|
|
|
|
public async Task ClearDefaultAsync(int customerId, int? excludeId = null, CancellationToken cancellationToken = default)
|
|
{
|
|
var list = await GetListAsync(
|
|
x => x.CustomerId == customerId && x.IsDefault == 1
|
|
&& (!excludeId.HasValue || x.Id != excludeId.Value),
|
|
cancellationToken: cancellationToken);
|
|
if (list.Count == 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
foreach (var item in list)
|
|
{
|
|
item.IsDefault = 0;
|
|
await UpdateAsync(item);
|
|
}
|
|
}
|
|
}
|