using IRaCIS.Core.Domain.Share;

namespace IRaCIS.Core.Domain.Models;

[Comment("后台 - 用户账户操作日志")]
[Table("UserLog")]
public class UserLog : BaseAddAuditEntity
{
    #region 导航属性
    [JsonIgnore]
    public IdentityUser TargetIdentityUser { get; set; }


    [JsonIgnore]
    public IdentityUser ActionIdentityUser { get; set; }

    #endregion

    public string IP { get; set; } = string.Empty;
    public UserOptType OptType { get; set; }
    public string LoginPassword { get; set; } = string.Empty;

    public string IPRegion { get; set; } = string.Empty;


    #region 账号修改 维护

    public Guid? ActionIdentityUserId { get; set; }

    public string ActionUserName { get; set; }

    public string ActionUserType { get; set; }


    [MaxLength]
    public string JsonObj { get; set; }


    [Comment("被操作的对象  admin 修改张三信息 张三是被操作对象")]
    public Guid? TargetIdentityUserId { get; set; }

    #endregion

    [Comment("异地登录")]
    public bool IsLoginUncommonly { get; set; }

    [Comment("是否忽略异地登录")]
    public bool IsIgnoreUncommonly { get; set; }



    #region 后续删除
    public string LoginFaildName { get; set; } = string.Empty;

    [Comment("后续删除")]
    public Guid? LoginUserId { get; set; }
    [Comment("被操作的人,自己操作的就是自己--后续删除")]
    public Guid? OptUserId { get; set; }
    #endregion



}


public class UserLogJsonObj
{
    public string FullName => LastName + " / " + FirstName;

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

    public string FirstName { get; set; }

    public string LastName { 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; }

    public string DepartmentName { get; set; }

    public List<UserRoleLogObj> UserRoleList { get; set; }

}


public class UserRoleLogObj
{
    public string UserTypeShortName { get; set; }

    public UserTypeEnum UserTypeEnum { get; set; }

    public bool IsUserRoleDisabled { get; set; }
}