mirror of
https://github.com/nsnail/NetAdmin.git
synced 2025-04-20 05:02:50 +08:00
fix: 🐛 请求日志批量插入,漏写了登录日志 (#210)
Co-authored-by: tk <fiyne1a@dingtalk.com>
This commit is contained in:
parent
4e9f605ea2
commit
6c71c74a27
@ -122,7 +122,6 @@ public sealed class VerifyCodeService(BasicRepository<Sys_VerifyCode, long> rpo,
|
||||
QueryVerifyCodeRsp ret;
|
||||
|
||||
#if !DEBUG
|
||||
|
||||
// 有发送记录,且小于1分钟,不允许
|
||||
if (lastSent != null && (DateTime.Now - lastSent.CreatedTime).TotalMinutes < 1) {
|
||||
throw new NetAdminInvalidOperationException(Ln._1分钟内只能发送1次);
|
||||
|
@ -16,9 +16,9 @@ public sealed class RequestLogCache(IDistributedCache cache, IRequestLogService
|
||||
/// <inheritdoc />
|
||||
#if !DEBUG
|
||||
public async Task<long> CountAsync(QueryReq<QueryRequestLogReq> req)
|
||||
#else
|
||||
#else
|
||||
public Task<long> CountAsync(QueryReq<QueryRequestLogReq> req)
|
||||
#endif
|
||||
#endif
|
||||
{
|
||||
#if !DEBUG
|
||||
var ret = await GetOrCreateAsync( //
|
||||
|
@ -1,6 +1,7 @@
|
||||
#if !DEBUG && DBTYPE_SQLSERVER
|
||||
using System.Collections.Concurrent;
|
||||
using NetAdmin.Domain.DbMaps.Sys;
|
||||
using NetAdmin.Domain.Dto.Sys.LoginLog;
|
||||
using NetAdmin.Domain.Dto.Sys.RequestLog;
|
||||
using NetAdmin.Domain.Events.Sys;
|
||||
|
||||
@ -42,6 +43,11 @@ public sealed class OperationLogger : IEventSubscriber
|
||||
}
|
||||
|
||||
inserts.Add(log);
|
||||
|
||||
// 插入登录日志
|
||||
if (log.ApiPathCrc32 == Chars.FLG_PATH_API_SYS_USER_LOGIN_BY_PWD.Crc32()) {
|
||||
_ = await App.GetService<ILoginLogCache>().CreateAsync(log.Adapt<CreateLoginLogReq>()).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
// 如果首尾日期不一致,要分别插入不同的日期分表
|
||||
@ -81,7 +87,7 @@ public sealed class OperationLogger : IEventSubscriber
|
||||
return;
|
||||
}
|
||||
|
||||
_ = await App.GetService<IRequestLogService>().CreateAsync(operationEvent.Data).ConfigureAwait(false);
|
||||
_ = await App.GetService<IRequestLogCache>().CreateAsync(operationEvent.Data).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user