using FreeSql.DataAnnotations;

namespace BookmarkApi.Data.Entities;

/// <summary>
/// 收藏集合实体
/// </summary>
[Table(Name = "collections")]
[Index("idx_collection_user", nameof(UserId))]
public class Collection
{
    /// <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 = 200)]
    public string Name { get; set; } = string.Empty;

    /// <summary>
    /// 描述
    /// </summary>
    [Column(StringLength = 500)]
    public string? Description { get; set; }

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

    /// <summary>
    /// 主题色
    /// </summary>
    [Column(StringLength = 20)]
    public string? Color { get; set; }

    /// <summary>
    /// 是否公开
    /// </summary>
    [Column(IsNullable = false)]
    public bool IsPublic { 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>
    [Column(ServerTime = DateTimeKind.Utc)]
    public DateTime UpdatedAt { get; set; }

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

    /// <summary>
    /// 导航属性 - 集合书签关联
    /// </summary>
    [Navigate(nameof(CollectionBookmark.CollectionId))]
    public virtual List<CollectionBookmark>? CollectionBookmarks { get; set; }
}
