using FreeSql.DataAnnotations;

namespace BookmarkApi.Data.Entities;

/// <summary>
/// 书签-设备权限关联实体
/// </summary>
[Table(Name = "bookmark_device_permissions")]
[Index("idx_permission_unique", nameof(BookmarkId) + "," + nameof(DeviceId), IsUnique = true)]
[Index("idx_permission_device", nameof(DeviceId))]
public class BookmarkDevicePermission
{
    /// <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 DeviceId { 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(DeviceId))]
    public virtual Device? Device { get; set; }
}
