using FreeSql.DataAnnotations;

namespace BookmarkApi.Data.Entities;

/// <summary>
/// 书签-标签关联实体
/// </summary>
[Table(Name = "bookmark_tags")]
[Index("idx_bookmark_tag_unique", nameof(BookmarkId) + "," + nameof(TagId), IsUnique = true)]
[Index("idx_tag_bookmarks", nameof(TagId))]
public class BookmarkTag
{
    /// <summary>
    /// 关联ID
    /// </summary>
    [Column(IsPrimary = true)]
    public Guid Id { get; set; }

    /// <summary>
    /// 书签ID
    /// </summary>
    [Column(IsNullable = false)]
    public Guid BookmarkId { get; set; }

    /// <summary>
    /// 标签ID
    /// </summary>
    [Column(IsNullable = false)]
    public Guid TagId { get; set; }

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

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

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