You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
2.4 KiB

7 months ago
using Entity.DbModel.System.SysBaseObject;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Service.Mgr
{
/// <summary>
/// 当前登录用户
/// </summary>
//[Scope("SingleInstance")]
public class UserManager
{
//private readonly IHttpContextAccessor _httpContextAccessor;
///// <summary>
///// 用户ID
///// </summary>
//public long UserId => (_httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.UserId)?.Value).ToLong();
///// <summary>
///// 用户账号
///// </summary>
//public string Account => _httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.Account)?.Value;
///// <summary>
///// 真实姓名
///// </summary>
//public string RealName => _httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.RealName)?.Value;
///// <summary>
///// 是否超级管理员
///// </summary>
//public bool SuperAdmin => _httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.AccountType)?.Value == ((int)AccountTypeEnum.SuperAdmin).ToString();
///// <summary>
///// 是否系统管理员
///// </summary>
//public bool SysAdmin => _httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.AccountType)?.Value == ((int)AccountTypeEnum.SysAdmin).ToString();
//public UserManager(IHttpContextAccessor httpContextAccessor)
//{
// _httpContextAccessor = httpContextAccessor;
//}
/// <summary>
/// 用户ID
/// </summary>
public static long UserId;
/// <summary>
/// 用户账号
/// </summary>
public static string Account;
/// <summary>
/// 真实姓名
/// </summary>
public static string RealName;
/// <summary>
/// 是否超级管理员
/// </summary>
public static bool SuperAdmin;
/// <summary>
/// 是否系统管理员
/// </summary>
public static bool SysAdmin;
public void SetManagerContent(SysUser user)
{
UserId = user.Id;
Account = user.Account;
RealName = user.RealName;
SuperAdmin = user.RealName == "超级管理员" ? true : false;
SysAdmin = user.RealName == "系统管理员" ? true : false;
}
}
}