using MessagePack;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace XPrintServer.DataModel.Models
{
    ///<summary>
    ///后台管理用户表
    ///</summary>
    [SugarIndex("idx_{split_table}_create_time", nameof(CreateTime), OrderByType.Desc)]
    [SplitTable(SplitType.Year)]//按年分表 （自带分表支持 年、季、月、周、日）
    [SugarTable("backstage_user_{year}{month}{day}")]//3个变量必须要有，这么设计为了兼容开始按年，后面改成按月、按日
    public partial class BackstageUser
    {
        public BackstageUser()
        {
            this.Platform = Convert.ToInt16("0");
        }

        /// <summary>
        /// Desc:Id
        /// Default:
        /// Nullable:False
        /// </summary>           
        [Key("Id")]
        [SugarColumn(IsPrimaryKey = true, ColumnDescription = "主键Id")]
        public Guid Id { get; set; }

        /// <summary>
        /// Desc:用户名
        /// Default:
        /// Nullable:False
        /// </summary>    
        [Key("UserName")]
        [SugarColumn(IsNullable = false, ColumnDescription = "用户名")]
        public string UserName { get; set; } = null!;

        /// <summary>
        /// Desc:Password
        /// Default:
        /// Nullable:False
        /// </summary>     
        [Key("Password")]
        [SugarColumn(IsNullable = false, ColumnDescription = "用户密码")]
        public string Password { get; set; } = null!;

        /// <summary>
        /// Desc:用户昵称
        /// Default:
        /// Nullable:True
        /// </summary>     
        [Key("NickName")]
        [SugarColumn(IsNullable = true, ColumnDescription = "用户昵称")]
        public string? NickName { get; set; }

        /// <summary>
        /// Desc:Password
        /// Default:
        /// Nullable:True
        /// </summary>     
        [Key("IsActive")]
        [SugarColumn(IsNullable = false, ColumnDescription = "用户是否是激活状态")]
        public bool IsActive { get; set; } = false;

        /// <summary>
        /// Desc:用户头像URL
        /// Default:
        /// Nullable:True
        /// </summary>      
        [Key("AvatarUrl")]
        [SugarColumn(IsNullable = true, ColumnDescription = "用户头像URL")]
        public string? AvatarUrl { get; set; }

        /// <summary>
        /// Desc:登录平台： 1：微信端浏览器，2：PC端浏览器，3：android，4：iOS，5：微信小程序，0：未知。
        /// Default:0
        /// Nullable:False
        /// </summary>    
        [Key("Platform")]
        [SugarColumn(ColumnDescription = "登录平台： 1：微信端浏览器，2：PC端浏览器，3：android，4：iOS，5：微信小程序，0：未知")]
        public short Platform { get; set; }

        /// <summary>
        /// Desc:注册时间
        /// Default:
        /// Nullable:True
        /// </summary>        
        [Key("RegisterTime")]
        [SugarColumn(IsNullable = true, ColumnDescription = "注册时间")]
        public DateTime? RegisterTime { get; set; }

        /// <summary>
        /// Desc:最后登录时间
        /// Default:
        /// Nullable:True
        /// </summary>    
        [Key("LoginTime")]
        [SugarColumn(IsNullable = true, ColumnDescription = "最后登录时间")]
        public DateTime? LoginTime { get; set; }

        /// <summary>
        /// Desc:
        /// Default:
        /// Nullable:False
        /// </summary>           
        [SugarColumn(IsNullable = false, ColumnDescription = "角色Id")]
        public Guid RoleId { get; set; }


        /// <summary>
        /// 分表字段 在插入的时候会根据这个字段插入哪个表，在更新删除的时候用这个字段找出相关表
        /// </summary>
        [Key("CreateTime")]
        [SplitField] //分表字段 在插入的时候会根据这个字段插入哪个表，在更新删除的时候用这个字段找出相关表
        public DateTime CreateTime { get; set; }

    }
}
