using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Text.Json.Serialization; namespace Blahblah.FlowerStory.Server.Data.Model; /// /// 用户对象 /// [Table("users")] public class UserItem { /// /// 自增 id,主键 /// [Column("uid")] [Key] [Required] public int Id { get; set; } /// /// 用户 id /// [Column("id")] [Required] public required string UserId { get; set; } /// /// 密码,值为 SHA256(password+id+salt) /// [Column("password")] [Required] [JsonIgnore] public string? Password { get; set; } /// /// 用户级别 /// -1: Disabled /// 0: Common /// 99: Admin /// [Column("level")] [Required] public int Level { get; set; } /// /// 注册时间 /// [Column("regdate")] [Required] [JsonPropertyName("registerDate")] public long RegisterDateUnixTime { get; set; } /// /// 最后变动时间 /// [Column("activedate")] [JsonIgnore] public long? ActiveDateUnixTime { get; set; } /// /// 用户名 /// [Column("name")] [Required] public required string Name { get; set; } /// /// 邮箱 /// [Column("email")] public string? Email { get; set; } /// /// 联系电话 /// [Column("mobile")] public string? Mobile { get; set; } /// /// 用户头像 /// [Column("avatar")] [JsonIgnore] public byte[]? Avatar { get; set; } /// /// 注册时间 /// [NotMapped] [JsonIgnore] public DateTimeOffset RegisterDate => DateTimeOffset.FromUnixTimeMilliseconds(RegisterDateUnixTime); /// /// 最后变动时间 /// [NotMapped] [JsonIgnore] public DateTimeOffset? ActiveDate => ActiveDateUnixTime == null ? null : DateTimeOffset.FromUnixTimeMilliseconds(ActiveDateUnixTime.Value); }