using EntityFrameworkCore.Projectables;
using IRaCIS.Core.Domain.Share;

namespace IRaCIS.Core.Domain.Models;

[Comment("后台 - 系统账户角色关系表")]
[Table("User")]
public class UserRole : BaseFullAuditEntity
{
    #region 导航属性

    [ForeignKey("IdentityUserId")]
    [JsonIgnore]
    public IdentityUser IdentityUser { get; set; }

    [JsonIgnore]

    [ForeignKey("UserTypeId")]
    public UserType UserTypeRole { get; set; }


    [JsonIgnore]
    public List<TrialUserRole> UserRoleTrials { get; set; } = new List<TrialUserRole>();

    [JsonIgnore]
    public List<VisitTask> VisitTaskList { get; set; }

    [Projectable]
    public string FullName => LastName + " / " + FirstName;

    #endregion

    public string UserName { get; set; }
    public string EMail { get; set; }
    public string FirstName { get; set; }

    public string LastName { get; set; }


    [Comment("自动切换下一个任务")]
    public bool AutoCutNextTask { get; set; }

    #region 后续删除用户信息

    public int Code { get; set; }
    public string UserCode { get; set; }
  

    public string Password { get; set; }


    public string Phone { get; set; }
    public string OrganizationName { get; set; }

    [StringLength(1000)]
    public string EmailToken { get; set; }


    public bool PasswordChanged { get; set; }
    public int? Sex { get; set; }

    public UserStateEnum Status { get; set; } = UserStateEnum.Enable;


    public string PositionName { get; set; }


    public string DepartmentName { get; set; }

    [Comment("首次登录需要修改密码")]
    public bool IsFirstAdd { get; set; } = true;

    public bool IsTestUser { get; set; }

    [Comment("内部用户  外部用户")]
    public bool IsZhiZhun { get; set; }

    [Comment("上一次修改密码的时间")]
    public DateTime? LastChangePassWordTime { get; set; }

    public string LastLoginIP { get; set; }

    public DateTime? LastLoginTime { get; set; }

    [Comment("后续删除")]
    public bool SuperAdmin { get; set; }


    #endregion



    [Comment("医生生成账号后,会有值")]
    public Guid? DoctorId { get; set; }

    public UserTypeEnum UserTypeEnum { get; set; }

    public Guid UserTypeId { get; set; }

    #region 新增字段

    public Guid IdentityUserId { get; set; }

    public bool IsUserRoleDisabled { get; set; }

    #endregion
}

[Comment("后台 - 系统真实账户表")]
[Table("IdentityUser")]
public class IdentityUser: BaseFullAuditEntity
{
    [JsonIgnore]
    public List<TrialIdentityUser> UserTrialList { get; set; }

    [JsonIgnore]
    public List<UserRole> UserRoleList { get; set; } = new List<UserRole>();

    [JsonIgnore]
    public List<SystemDocConfirmedIdentityUser> SystemDocConfirmedList { get; set; }

    [Projectable]
    public string FullName => LastName + " / " + FirstName;

    #region 用户信息

    public int Code { get; set; }
    public string UserCode { get; set; }
    public string UserName { get; set; }
    public string EMail { get; set; }

    [StringLength(1000)]
    public string EmailToken { get; set; }

    public string FirstName { get; set; }

    public string LastName { get; set; }

    public string Password { get; set; }

    public bool PasswordChanged { get; set; }

    public string Phone { get; set; }

    public int? Sex { get; set; }

    public UserStateEnum Status { get; set; } = UserStateEnum.Enable;


    public string OrganizationName { get; set; }


    public string PositionName { get; set; }

    [Comment("这个字段废除,放在用户角色上面,后续删除")]
    public bool AutoCutNextTask { get; set; }

    public string DepartmentName { get; set; }

    [Comment("首次登录需要修改密码")]
    public bool IsFirstAdd { get; set; } = true;

    public bool IsTestUser { get; set; }

    [Comment("内部用户  外部用户")]
    public bool IsZhiZhun { get; set; }

    [Comment("上一次修改密码的时间")]
    public DateTime? LastChangePassWordTime { get; set; }

    public string LastLoginIP { get; set; }

    public DateTime? LastLoginTime { get; set; }


    #endregion
}