using AyCode.Core.Serializers.Attributes;
using AyCode.Core.Serializers.Toons;
using LinqToDB.Mapping;
using Mango.Nop.Core.Entities;

namespace FruitBank.Common.Entities;

[AcBinarySerializable(false, true, false, true, false, false)]
[Table(Name = FruitBankConstClient.ProductTextMappingDbTableName)]
[System.ComponentModel.DataAnnotations.Schema.Table(FruitBankConstClient.ProductTextMappingDbTableName)]
[ToonDescription("Historical record of admin product selections from free-text inputs", Purpose = "Every time an admin approves an OrderDraftItem and selects a product, a record is written here. Used to weight future AI suggestions: if the same raw text recently resolved to a given product, that product ranks first in SuggestedProductIds.")]
public sealed class ProductTextMapping : MgEntityBase
{
    [ToonDescription(Purpose = "The raw text as it came from the message (e.g. 'piros kalif'). Stored lowercase-trimmed for consistent matching.")]
    public string RawText { get; set; } = string.Empty;

    [ToonDescription(Purpose = "FK to the NopCommerce Product the admin selected for this raw text.")]
    public int ResolvedProductId { get; set; }

    [ToonDescription(Purpose = "Whether the selection was in a preorder context (true) or direct order context (false). Allows separate weighting per context.")]
    public bool IsPreorder { get; set; }

    [ToonDescription(Purpose = "The admin who made this selection.")]
    public int SelectedByAdminId { get; set; }

    public DateTime CreatedOnUtc { get; set; }
}