schangxiang@126.com
2024-04-23 f47411fb53aeee0c7bd514cbc841f9030349f448
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using Admin.NET.Core;
using Furion;
using Furion.FriendlyException;
 
namespace Admin.NET.Application
{
    /// <summary>
    /// 当前用户
    /// </summary>
    public static class CurrentUserInfo
    {
        /// <summary>
        /// 用户id
        /// </summary>
        public static long UserId => App.User.FindFirst(ClaimConst.CLAINM_USERID) == null ? throw Oops.Oh(SysConst.SYS_SESSION_OUT) : long.Parse(App.User.FindFirst(ClaimConst.CLAINM_USERID)?.Value);
 
        /// <summary>
        /// 账号
        /// </summary>
        public static string Account => App.User.FindFirst(ClaimConst.CLAINM_ACCOUNT) == null ? throw Oops.Oh(SysConst.SYS_SESSION_OUT) : App.User.FindFirst(ClaimConst.CLAINM_ACCOUNT)?.Value;
 
        /// <summary>
        /// 昵称
        /// </summary>
        public static string Name => App.User.FindFirst(ClaimConst.CLAINM_NAME) == null ? throw Oops.Oh(SysConst.SYS_SESSION_OUT) : App.User.FindFirst(ClaimConst.CLAINM_NAME)?.Value;
 
        /// <summary>
        /// 是否超级管理员
        /// </summary>
        public static bool IsSuperAdmin =>  App.User.FindFirst(ClaimConst.CLAINM_SUPERADMIN)?.Value == ((int)AdminType.SuperAdmin).ToString();
    }
}