using YBEE.EQM.Core;

namespace YBEE.EQM.Application;

/// <summary>
/// 当前用户
/// </summary>
public class CurrentSysUserInfo
{
    /// <summary>
    /// 用户ID
    /// </summary>
    public static int SysUserId
    {
        get
        {
            if (int.TryParse(App.User.FindFirst(ClaimConst.CLAINM_USERID)?.Value, out int uid))
            {
                return uid;
            }
            return 0;
        }
    }
    /// <summary>
    /// 机构ID
    /// </summary>
    public static short SysOrgId
    {
        get
        {
            if (short.TryParse(App.User.FindFirst(ClaimConst.CLAINM_ORGID)?.Value, out short oid))
            {
                return oid;
            }
            return 0;
        }
    }
    /// <summary>
    /// 机构名称
    /// </summary>
    public static string SysOrgName => App.User.FindFirst(ClaimConst.CLAINM_ORGNAME)?.Value;
    /// <summary>
    /// 账号
    /// </summary>
    public static string Account => App.User.FindFirst(ClaimConst.CLAINM_ACCOUNT)?.Value;
    /// <summary>
    /// 名称
    /// </summary>
    public static string Name => App.User.FindFirst(ClaimConst.CLAINM_NAME)?.Value;
    /// <summary>
    /// 是否超级管理员
    /// </summary>
    public static bool IsSuperAdmin
    {
        get
        {
            if (bool.TryParse(App.User.FindFirst(ClaimConst.CLAINM_SUPERADMIN)?.Value ?? "False", out bool isSuperAdmin))
            {
                return isSuperAdmin;
            }
            return false;
        }
    }
}