增加项目,分层
This commit is contained in:
1 parent
6e995a5bdb
commit
0a3e5af6a9
234 files changed
+26994
-1
No files matched your search
@@ -0,0 +1,37 @@
|
||||
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);
|
||||
}
|
||||
|
||||
Task INotificationHandler<UserNotification>.Handle(UserNotification notification, CancellationToken cancellationToken)
|
||||
{
|
||||
User = notification.user;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user