ql_apimanager_backend/Apimanager_backend/Models/User.cs

75 lines
2.1 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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