Files
qhmes/yy-admin-master/YY.Admin.Core/Session/AppSession.cs

41 lines
896 B
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace YY.Admin.Core.Session
{
/// <summary>
/// 静态会话类
/// </summary>
public static class AppSession
{
private static SysUser? _currentUser;
private static readonly object _lock = new object();
public static SysUser? CurrentUser
{
get
{
lock (_lock)
{
return _currentUser;
}
}
set
{
lock (_lock)
{
_currentUser = value;
}
}
}
// 添加安全访问方法
public static bool IsAuthenticated => CurrentUser != null;
public static long? UserId => CurrentUser?.Id;
}
}