Files
StoreWeb/Models/CloudProduct/Dtos/ProductSearchInfo.cs
T

61 lines
1.8 KiB
C#

using OpenSearch.Client;
using System;
using System.Collections.Generic;
using System.Text;
namespace Store.Modules.CloudProduct.Dtos
{
/// <summary>
/// 商品搜索模型:Id 为主键,Title 用于分词搜索
/// </summary>
public class ProductSearchInfo
{
[Number(NumberType.Byte, Name = "platform")]
public byte Platform { get; set; }
[Number(NumberType.Long, Name = "id")]
public long Id { get; set; }
[Text(Name = "title", Analyzer = "ik_max_word", SearchAnalyzer = "ik_smart")]
public string Title { get; set; } = string.Empty;
[Text(Name = "thumbUrl")]
public string? ThumbUrl { get; set; } = string.Empty;
/// <summary>一级类目ID</summary>
[Number(NumberType.Integer, Name = "cat_id_1")]
public int? CatId1 { get; set; }
/// <summary>二级类目ID</summary>
[Number(NumberType.Integer, Name = "cat_id_2")]
public int? CatId2 { get; set; }
/// <summary>三级类目ID</summary>
[Number(NumberType.Integer, Name = "cat_id_3")]
public int? CatId3 { get; set; }
/// <summary>四级类目ID</summary>
[Number(NumberType.Integer, Name = "cat_id_4")]
public int? CatId4 { get; set; }
/// <summary>最低价快照,用于价格区间过滤和按价格排序</summary>
[Number(NumberType.Long, Name = "min_price")]
public long? MinPrice { get; set; }
/// <summary>销量,用于按销量排序</summary>
[Number(NumberType.Integer, Name = "sold_quantity")]
public int SoldQuantity { get; set; }
public override string ToString() => $"[Id={Id}] Title={Title} Cat=({CatId1},{CatId2},{CatId3},{CatId4}) Price={MinPrice} Sold={SoldQuantity}";
}
/// <summary>
/// 搜索排序方式
/// </summary>
public enum GoodsSearchSortBy
{
Relevance = 0, // 相关性(默认)
PriceAsc = 1, // 价格从低到高
PriceDesc = 2, // 价格从高到低
SoldDesc = 3, // 销量从高到低
}
}