using SqlSugar; using System; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Web.Security; namespace Models.ModelItems { #region 用户表 [Table("UserInfo")] public class UserInfo:ICloneable { //用户表 ID 密码 用户名 头像(有默认) 性别 年龄 说明 创建时间 到期时间 (默认2个月后) 所属酒店 所属酒店组 [SugarColumn(IsIdentity = true, IsPrimaryKey = true)] public int Id { get; set; } /// /// 用户标识(账号) /// [SugarColumn(ColumnDataType = "varchar(50)", IndexGroupNameList = new[] { "Uid_key" }) ] public string Uid { get; set; } /// /// 密码 /// [SugarColumn(ColumnDataType = "varchar(50)")] public string Pwd { get; set; } [SugarColumn(ColumnDataType = "varchar(255)",IsNullable =true)] public string PwdSee { get; set; } /// /// 头像url /// /// [SugarColumn(ColumnDataType = "varchar(255)", IsNullable = true, DefaultValue = "default.png")] public string HeadImg { get; set; } = "defaultboy.png"; /// /// 性别 0-3 0 男 1 女 2 未知 3 预留待定 默认0 /// [SugarColumn(ColumnDataType = "int")] public int? Sex { get; set; } = 0; /// /// 年龄 默认18 /// [SugarColumn(ColumnDataType = "int", IsNullable = true, DefaultValue = "18")] public int? Age { get; set; } = 18; /// /// 是否可用 0 可用 1 不可 2管理 /// [SugarColumn(ColumnDataType = "int", IsNullable = true)] public int? IsValid { get; set; } = 0; /// /// 说明 /// /// [SugarColumn(ColumnDataType = "varchar(255)", IsNullable = true)] public string Desc { get; set; } = ""; /// /// 创建时间 /// /// [SugarColumn(ColumnDataType = "datetime(3)", IsNullable = true)] public DateTime CreateTime { get; set; } = DateTime.Now; [SugarColumn(ColumnDataType = "datetime(3)", IsNullable = true)] public DateTime? EndTime { get; set; } = DateTime.Now.AddMonths(2); public object Clone() { return this.Clone(); } public UserInfo Clones() { return (UserInfo)this.Clone(); } /// /// 创建人 /// [SugarColumn(ColumnDataType = "varchar(255)", IsNullable = true)] public string CreatedBy { get; set; } = "系统"; /// /// 所属酒店 /// [SugarColumn(ColumnDataType = "int", IsNullable = true)] public int? HotelID { get; set; } = 0; [SugarColumn(ColumnDataType = "int", IsNullable = true)] public int? HotelGroupID { get; set; } = 0; /// /// 是否导入 1 导入 /// [SugarColumn(ColumnDataType = "int", IsNullable = true)] public int IsImport { get; set; } = 0; /// /// 酒店数量 /// [SugarColumn(ColumnDataType = "int", IsNullable = true)] public int Hotel_Count { get; set; } = 0; /// /// 所有酒店 /// [SugarColumn(ColumnDataType = "TEXT(21845)", IsNullable = true)] public string Hotel_Data { get; set; } = ""; /// /// 公司 0 宝来威 1 住好 2 卓豪 /// [SugarColumn(ColumnDataType = "int", IsNullable = true)] public int? Company { get; set; } [SugarColumn(ColumnDataType = "int", IsNullable = true)] public int? OldId { get; set; } = 0; [SugarColumn(ColumnDataType = "int")] //是否自动授权 public int Autho { get; set; } = 0; /// /// 创建时间 /// /// [SugarColumn(ColumnDataType = "datetime(3)", IsNullable = true)] public DateTime SyncTime { get; set; } = DateTime.Now; /// /// 计算密码 Hash值 /// /// /// /// public UserInfo ComputePasswordHash() { this.Pwd = HashCode(this.Uid.ToUpper() + this.Pwd + (this.CreateTime).ToString("yyyy-MM-dd HH:mm:ss")); return this; } /// /// 获取MD5值 /// /// 加密的字符串 /// 返回MD5值 public string HashCode(string key) { return FormsAuthentication.HashPasswordForStoringInConfigFile(key, "MD5"); } #endregion } }