using FreeSql.DataAnnotations;

namespace BookmarkApi.Data.Entities;

/// <summary>
/// 集合-书签关联实体
/// </summary>
[Table(Name = "collection_bookmarks")]
[Index("idx_collection_bookmark_unique", nameof(CollectionId) + "," + nameof(BookmarkId), IsUnique = true)]
[Index("idx_bookmark_collections", nameof(BookmarkId))]
public class CollectionBookmark
{
    /// <summary>
    /// 关联ID
    /// </summary>
    [Column(IsPrimary = true)]
    public Guid Id { get; set; }

    /// <summary>
    /// 集合ID
    /// </summary>
    [Column(IsNullable = false)]
    public Guid CollectionId { get; set; }

    /// <summary>
    /// 书签ID
    /// </summary>
    [Column(IsNullable = false)]
    public Guid BookmarkId { 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(CollectionId))]
    public virtual Collection? Collection { get; set; }

    /// <summary>
    /// 导航属性 - 书签
    /// </summary>
    [Navigate(nameof(BookmarkId))]
    public virtual Bookmark? Bookmark { get; set; }
}
