File size: 1,119 Bytes
5fc700d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | using FreeSql.DataAnnotations;
namespace ToolHub.Models;
[Table(Name = "UserToolAccesses")]
public class UserToolAccess
{
[Column(IsIdentity = true, IsPrimary = true)]
public int Id { get; set; }
public int? UserId { get; set; } // 可为空,支持匿名用户
public int ToolId { get; set; }
[Column(StringLength = 50)]
public string? SessionId { get; set; } // 会话ID,用于匿名用户跟踪
[Column(StringLength = 45)]
public string? IpAddress { get; set; } // IP地址
[Column(StringLength = 500)]
public string? UserAgent { get; set; } // 用户代理
[Column(StringLength = 100)]
public string? Referer { get; set; } // 来源页面
[Column(StringLength = 20)]
public string AccessType { get; set; } = "view"; // view, favorite, share, download
public int Duration { get; set; } = 0; // 停留时间(秒)
public DateTime CreatedAt { get; set; } = DateTime.Now;
// 导航属性
[Navigate(nameof(UserId))]
public User? User { get; set; }
[Navigate(nameof(ToolId))]
public Tool Tool { get; set; } = null!;
}
|