feat: 商品列表查询改为数据库分页过滤
All checks were successful
Build and Deploy TenantApi + SkuWorker / build-and-deploy (push) Successful in 1m53s
All checks were successful
Build and Deploy TenantApi + SkuWorker / build-and-deploy (push) Successful in 1m53s
This commit is contained in:
@@ -18,6 +18,13 @@ public interface IProductRepository
|
||||
/// </summary>
|
||||
Task<IReadOnlyList<Product>> SearchAsync(long tenantId, long? storeId, long? categoryId, ProductStatus? status, CancellationToken cancellationToken = default, DateTime? updatedAfter = null);
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询商品列表。
|
||||
/// </summary>
|
||||
Task<(IReadOnlyList<Product> Items, int Total)> SearchPagedAsync(
|
||||
ProductSearchFilter filter,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// 获取租户下的商品分类。
|
||||
/// </summary>
|
||||
@@ -499,3 +506,64 @@ public interface IProductRepository
|
||||
/// <returns>异步任务。</returns>
|
||||
Task RemovePricingRulesAsync(long productId, long tenantId, CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 商品分页查询过滤条件。
|
||||
/// </summary>
|
||||
public sealed record ProductSearchFilter
|
||||
{
|
||||
/// <summary>
|
||||
/// 租户 ID。
|
||||
/// </summary>
|
||||
public long TenantId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 门店 ID(可选)。
|
||||
/// </summary>
|
||||
public long? StoreId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 分类 ID(可选)。
|
||||
/// </summary>
|
||||
public long? CategoryId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 状态过滤。
|
||||
/// </summary>
|
||||
public ProductStatus? Status { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 商品类型过滤。
|
||||
/// </summary>
|
||||
public ProductKind? Kind { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 关键字(名称/SPU)。
|
||||
/// </summary>
|
||||
public string? Keyword { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否仅沽清商品。
|
||||
/// </summary>
|
||||
public bool? IsSoldOut { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 页码(从 1 开始)。
|
||||
/// </summary>
|
||||
public int Page { get; init; } = 1;
|
||||
|
||||
/// <summary>
|
||||
/// 每页条数。
|
||||
/// </summary>
|
||||
public int PageSize { get; init; } = 20;
|
||||
|
||||
/// <summary>
|
||||
/// 排序字段(name/price/status/createdAt)。
|
||||
/// </summary>
|
||||
public string? SortBy { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否倒序。
|
||||
/// </summary>
|
||||
public bool SortDescending { get; init; } = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user