81 lines
2.2 KiB
C#
Raw Normal View History

2024-10-13 17:04:47 +08:00
using LMS.Repository.User;
2024-10-13 22:09:08 +08:00
using LMS.Tools.Extensions;
2024-10-13 17:04:47 +08:00
using Microsoft.AspNetCore.Identity;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json;
namespace LMS.Repository.Models.DB
{
public class User : IdentityUser<long>
{
[MaxLength(50)]
public string NickName { get; set; }
/// <summary>
/// 允许使用的机器码数量
/// </summary>
public long AllDeviceCount { get; set; } = 1;
/// <summary>
/// 代理分成比例
/// </summary>
public double AgentPercent { get; set; } = 0.00;
/// <summary>
/// 免费修改机器码次数
/// </summary>
public long FreeCount { get; set; } = 0;
/// <summary>
/// 用户的一些简单的操作
/// </summary>
[Column(TypeName = "json")]
public string? Options { get; set; } = "{}";
[Column(TypeName = "datetime")]
2024-10-13 22:09:08 +08:00
public DateTime CreatedDate { get; set; } = BeijingTimeExtension.GetBeijingTime();
2024-10-13 17:04:47 +08:00
[Column(TypeName = "datetime")]
2024-10-13 22:09:08 +08:00
public DateTime UpdatedDate { get; set; } = BeijingTimeExtension.GetBeijingTime();
2024-10-13 17:04:47 +08:00
[Column(TypeName = "datetime")]
2024-10-13 22:09:08 +08:00
public DateTime LastLoginDate { get; set; } = BeijingTimeExtension.GetBeijingTime();
2024-10-13 17:04:47 +08:00
public string? LastLoginIp { get; set; } = "";
public string? LastLoginDevice { get; set; } = "";
/// <summary>
/// 上级ID
/// </summary>
public long? ParentId { get; set; }
/// <summary>
/// 推广码
/// </summary>
public string AffiliateCode { get; set; } = string.Empty;
/// <summary>
/// 用户微信号
/// </summary>
public string? WXNumber { get; set; }
/// <summary>
/// 备注
/// </summary>
public string? Remark { get; set; }
2024-10-13 17:04:47 +08:00
/// <summary>
/// 实际使用的Options
/// </summary>
[NotMapped]
public UserPrivateOptions OptionsJson
{
get => JsonSerializer.Deserialize<UserPrivateOptions>(Options ?? "{}") ?? new UserPrivateOptions();
set => Options = JsonSerializer.Serialize(value);
}
}
}