42 lines
1012 B
C#
42 lines
1012 B
C#
using MAX.Core.DependencyInjection;
|
|
using MediatR;
|
|
using Store.Framework.Inerterfaces;
|
|
using Store.Framework.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Store.Framework.Services;
|
|
|
|
//public record UserNotification(UserInfo user) : INotification;
|
|
/// <summary>
|
|
/// 当前用户
|
|
/// </summary>
|
|
internal class CurrentUserService : ICurrentUser, ISingletonDependency//, INotificationHandler<UserNotification>
|
|
{
|
|
public string UserName => User?.UserName;
|
|
|
|
public int GroupId => User.GroupId;
|
|
|
|
public UserInfo User { get; private set; }
|
|
|
|
public bool IsSuperAdmin => User.IsSa;
|
|
|
|
public bool IsAuthorized(string code)
|
|
{
|
|
return User.UserAuthority.Contains(code);
|
|
}
|
|
internal void SetUser(UserInfo user)
|
|
{
|
|
User = user;
|
|
}
|
|
|
|
//Task INotificationHandler<UserNotification>.Handle(UserNotification notification, CancellationToken cancellationToken)
|
|
//{
|
|
// User = notification.user;
|
|
// return Task.CompletedTask;
|
|
//}
|
|
}
|