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; /// /// 当前用户 /// internal class CurrentUserService : ICurrentUser, ISingletonDependency, INotificationHandler { 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); } Task INotificationHandler.Handle(UserNotification notification, CancellationToken cancellationToken) { User = notification.user; return Task.CompletedTask; } }