using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
namespace Apimanager_backend.Models
{
public class User
{
///
/// 用户ID,主键,自增
///
public int Id { get; set; }
///
/// 用户名,唯一
///
[Required]
public string Username { get; set; } // varchar(20)
public string? Avatar { get; set; }
///
/// 邮箱,唯一
///
public string Email { get; set; } // varchar(20)
///
/// 密码哈希
///
[Required]
[MaxLength(255)]
public string PassHash { get; set; } // varchar(255)
///
/// 用户角色
///
//public UserRole Role { get; set; } // Enum('Admin','User')
///
/// 是否禁用
///
public bool IsBan { get; set; } = false; // boolean
///
/// 是否删除
///
public bool IsDelete { get; set; } = false; // boolean
///
/// 余额
///
public decimal Balance { get; set; } = 0; // Decimal(10)
///
/// api调用凭证
///
public string? ApiKey { get; set; } = null;
///
/// 创建时间,默认当前时间
///
public DateTime CreatedAt { get; set; } = DateTime.UtcNow; // Timestamp
//导航属性
[JsonIgnore]
public ICollection Packages { get; set; }
[JsonIgnore]
public ICollection operationLogs { get; set; }
public ICollection CallLogs { get; set; }
[JsonIgnore]
public ICollection Orders { get; set; }
public ICollection Roles { get; set; } = new List();
public User(int id,string username,string email,string passHash)
{
this.Id = id;
this.Username = username;
this.PassHash = passHash;
this.Email = email;
}
public User() { }
}
}