This commit is contained in:
2023-05-31 10:19:05 +08:00
parent 1b65a7a9e5
commit 9c621c75cd
238 changed files with 9905 additions and 4034 deletions

View File

@@ -1,6 +1,7 @@
using JNPF.Common.Configuration;
using JNPF.DependencyInjection;
using JNPF.EventBus;
using JNPF.Systems.Interfaces.Permission;
using SqlSugar;
namespace JNPF.EventHandler;
@@ -15,12 +16,20 @@ public class UserEventSubscriber : IEventSubscriber, ISingleton
/// </summary>
private static SqlSugarScope? _sqlSugarClient;
/// <summary>
/// 用户服务.
/// </summary>
private readonly IUsersService _usersService;
/// <summary>
/// 构造函数.
/// </summary>
public UserEventSubscriber(ISqlSugarClient context)
public UserEventSubscriber(
ISqlSugarClient context,
IUsersService usersService)
{
_sqlSugarClient = (SqlSugarScope)context;
_usersService = usersService;
}
/// <summary>
@@ -39,7 +48,7 @@ public class UserEventSubscriber : IEventSubscriber, ISingleton
_sqlSugarClient.ChangeDatabase(log.ConnectionConfig.ConfigId);
}
await _sqlSugarClient.Updateable(log.Entity).UpdateColumns(m => new { m.FirstLogIP, m.FirstLogTime, m.PrevLogTime, m.PrevLogIP, m.LastLogTime, m.LastLogIP, m.LogSuccessCount }).ExecuteCommandAsync();
await _sqlSugarClient.CopyNew().Updateable(log.Entity).UpdateColumns(m => new { m.FirstLogIP, m.FirstLogTime, m.PrevLogTime, m.PrevLogIP, m.LastLogTime, m.LastLogIP, m.LogSuccessCount }).ExecuteCommandAsync();
}
/// <summary>
@@ -47,9 +56,10 @@ public class UserEventSubscriber : IEventSubscriber, ISingleton
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
[EventSubscribe("User:maxkey_identity")]
[EventSubscribe("User:Maxkey_Identity")]
public async Task ReceiveUserInfo(EventHandlerExecutingContext context)
{
var log = (UserEventSource)context.Source;
var log = context.Source.Payload;
await _usersService.Receive(log.ToString());
}
}