using SqlSugar; using System.ComponentModel.DataAnnotations; using WoodWood.Util.Validations; namespace Wood.Entity.SystemManage { /// /// 用户共享信息 /// public class UserEntityShared : EntityTenantBaseExtra { /// /// 用户名 /// [SugarColumn(ColumnDescription = "用户名", Length = 16)] [Required] [UniqueValue(EntityType=typeof(UserEntity),ErrorMessage ="用户名不能重复!")] public string UserName { get; set; } = ""; /// /// 真实姓名 /// [SugarColumn(ColumnDescription = "真实姓名", Length = 16, IsNullable = true)] [Required] public string? RealName { get; set; } /// /// 昵称 /// [SugarColumn(ColumnDescription = "昵称", Length = 32, IsNullable = true)] public string? NickName { get; set; } /// /// 性别 1 男 0 女 /// [SugarColumn(ColumnDescription = "性别 1 男 0 女", DefaultValue = "0")] [Required] public int Gender { get; set; } = 0; /// /// 出生日期 /// [SugarColumn(ColumnDescription = "出生日期",IsNullable =true)] public DateTime? Birthday { get; set; } /// /// 邮箱 /// [SugarColumn(ColumnDescription = "邮箱", Length = 64, IsNullable = true)] public string? Email { get; set; } /// /// 手机号码 /// [SugarColumn(ColumnDescription = "手机号码", Length = 16, IsNullable = true)] [Required] public string? Mobile { get; set; } /// /// 头像 /// [SugarColumn(ColumnDescription = "头像", Length = 32, IsNullable = true)] public string? Avatar { get; set; } } /// /// 用户信息表 /// [SugarTable("SysUser", "用户信息表")] public class UserEntity : UserEntityShared,IDiff { /// /// 密码 /// [SugarColumn(ColumnDescription = "密码", Length = 512)] public string Password { get; set; } = ""; /// /// 加密盐值 /// [SugarColumn(ColumnDescription = "加密盐值", Length = 16)] public string Salt { get; set; } = ""; /// /// 部门id /// [SugarColumn(ColumnDescription = "部门id", DefaultValue = "0")] public long OrgId { get; set; } = 0; /// /// 职位id /// [SugarColumn(ColumnDescription = "职位id", DefaultValue = "0")] public long PositionId { get; set; } = 0; /// /// 最近登录时间 /// [SugarColumn(ColumnDescription = "最近登录时间", IsNullable = true)] public DateTime? LastVisit { get; set; } /// /// 账号类型 /// [SugarColumn(ColumnDescription = "账号类型", DefaultValue = "0")] public AccountTypeEnum AccountType { get; set; } = 0; /// /// 登录次数 /// [SugarColumn(ColumnDescription = "登录次数", DefaultValue = "0")] public int LoginCount { get; set; } = 0; /// /// 第一次登录时间 /// [SugarColumn(ColumnDescription = "第一次登录时间", IsNullable = true)] public DateTime? FirstVisit { get; set; } /// /// 上次登录时间 /// [SugarColumn(ColumnDescription = "前次登录时间", IsNullable = true)] public DateTime? PreviousVisit { get; set; } /// /// 部门信息 /// [Navigate(NavigateType.OneToOne, nameof(OrgId))] public OrgEntity? Org { get; set; } /// /// 职位信息 /// [Navigate(NavigateType.OneToOne, nameof(PositionId))] public PositionEntity? Position { get; set; } /// /// 角色信息 /// [Navigate(typeof(UserBelongRoleEntity), nameof(UserBelongRoleEntity.UserId), nameof(UserBelongRoleEntity.RoleId))]//注意顺序 public List? Roles { get; set; } } }