using FreeSql.DataAnnotations;

namespace BookmarkApi.Data.Entities;

/// <summary>
/// 标签实体
/// </summary>
[Table(Name = "tags")]
[Index("idx_tag_user_name", nameof(UserId) + "," + nameof(Name), IsUnique = true)]
public class Tag
{
    /// <summary>
    /// 标签ID
    /// </summary>
    [Column(IsPrimary = true)]
    public Guid Id { get; set; }

    /// <summary>
    /// 所属用户ID
    /// </summary>
    [Column(IsNullable = false)]
    public Guid UserId { get; set; }

    /// <summary>
    /// 标签名称
    /// </summary>
    [Column(IsNullable = false, StringLength = 100)]
    public string Name { get; set; } = string.Empty;

    /// <summary>
    /// 颜色值（如 #FF5733）
    /// </summary>
    [Column(StringLength = 20)]
    public string? Color { get; set; }

    /// <summary>
    /// 图标
    /// </summary>
    [Column(StringLength = 100)]
    public string? Icon { get; set; }

    /// <summary>
    /// 排序
    /// </summary>
    [Column(IsNullable = false)]
    public int Order { get; set; }

    /// <summary>
    /// 创建时间
    /// </summary>
    [Column(ServerTime = DateTimeKind.Utc, CanUpdate = false)]
    public DateTime CreatedAt { get; set; }

    /// <summary>
    /// 导航属性 - 所属用户
    /// </summary>
    [Navigate(nameof(UserId))]
    public virtual User? User { get; set; }

    /// <summary>
    /// 导航属性 - 书签标签关联
    /// </summary>
    [Navigate(nameof(BookmarkTag.TagId))]
    public virtual List<BookmarkTag>? BookmarkTags { get; set; }
}
