From 6fc6829bc8121d4735f4bde170c7148fdf78d256 Mon Sep 17 00:00:00 2001
From: hang <872297557@qq.com>
Date: Wed, 5 Jul 2023 09:35:38 +0800
Subject: [PATCH] =?UTF-8?q?hang-S-002=E5=A2=9E=E5=8A=A0=E6=9E=9A=E4=B8=BE?=
=?UTF-8?q?=EF=BC=8C=E4=BF=AE=E6=94=B9=E5=AF=86=E7=A0=81=EF=BC=8C=E9=87=8D?=
=?UTF-8?q?=E7=BD=AE=E5=AF=86=E7=A0=81=EF=BC=8C=E8=AE=B0=E5=BD=95=E6=97=A5?=
=?UTF-8?q?=E5=BF=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Service/Management/DTO/UserLogViewModel.cs | 2 ++
.../Service/Management/UserLogService.cs | 10 +++++++---
.../Service/Management/UserService.cs | 9 +++++++--
IRaCIS.Core.Domain/Management/UserLog.cs | 14 +++++++++++---
4 files changed, 27 insertions(+), 8 deletions(-)
diff --git a/IRaCIS.Core.Application/Service/Management/DTO/UserLogViewModel.cs b/IRaCIS.Core.Application/Service/Management/DTO/UserLogViewModel.cs
index 40d69d0c6..69021f38e 100644
--- a/IRaCIS.Core.Application/Service/Management/DTO/UserLogViewModel.cs
+++ b/IRaCIS.Core.Application/Service/Management/DTO/UserLogViewModel.cs
@@ -25,6 +25,8 @@ namespace IRaCIS.Core.Application.ViewModel
///UserLogQuery 列表查询参数模型
public class UserLogQuery : PageInput
{
+ public Guid? TrialId { get; set; }
+
public UserOptType? OptType { get; set; }
public string? IP { get; set; }
diff --git a/IRaCIS.Core.Application/Service/Management/UserLogService.cs b/IRaCIS.Core.Application/Service/Management/UserLogService.cs
index 1aaf7aa27..b1233aaad 100644
--- a/IRaCIS.Core.Application/Service/Management/UserLogService.cs
+++ b/IRaCIS.Core.Application/Service/Management/UserLogService.cs
@@ -18,21 +18,25 @@ namespace IRaCIS.Core.Application.Service
{
private readonly IRepository _userLogRepository;
+ private readonly IRepository _trialUserRepository;
- public UserLogService(IRepository userLogRepository)
+ public UserLogService(IRepository userLogRepository, IRepository trialUserRepository)
{
_userLogRepository = userLogRepository;
+ _trialUserRepository = trialUserRepository;
}
+
public async Task> GetUserLogList(UserLogQuery inQuery)
{
var userLogQueryable =
_userLogRepository
+ .WhereIf(inQuery.TrialId != null, t => t.CreateUser.UserTrials.Any(c => c.TrialId == inQuery.TrialId && c.UserId == t.CreateUserId))
.WhereIf(inQuery.OptType!=null ,t=>t.OptType==inQuery.OptType)
- .WhereIf(inQuery.BeginDate != null, t => t.CreateTime >= inQuery.BeginDate)
- .WhereIf(inQuery.EndDate != null, t => t.CreateTime <= inQuery.EndDate)
+ .WhereIf(inQuery.BeginDate != null, t => t.CreateTime >= inQuery.BeginDate)
+ .WhereIf(inQuery.EndDate != null, t => t.CreateTime <= inQuery.EndDate)
.WhereIf(!string.IsNullOrEmpty(inQuery.LoginName) , t => t.LoginName.Contains(inQuery.LoginName) )
.WhereIf(!string.IsNullOrEmpty(inQuery.IP), t => t.IP.Contains(inQuery.IP))
.WhereIf(!string.IsNullOrEmpty(inQuery.LoginName), t => t.LoginName.Contains(inQuery.LoginName))
diff --git a/IRaCIS.Core.Application/Service/Management/UserService.cs b/IRaCIS.Core.Application/Service/Management/UserService.cs
index 9305f852c..db3c324d9 100644
--- a/IRaCIS.Core.Application/Service/Management/UserService.cs
+++ b/IRaCIS.Core.Application/Service/Management/UserService.cs
@@ -295,6 +295,8 @@ namespace IRaCIS.Application.Services
IsFirstAdd = true
});
+ await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, CreateUserId = _userInfo.Id, LoginName = _userInfo.UserName, IsSuccess = true, OptType = UserOptType.AdminResetPassword }, true);
+
return ResponseOutput.Ok();
}
@@ -405,6 +407,8 @@ namespace IRaCIS.Application.Services
IsFirstAdd = false
});
+ await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, CreateUserId = _userInfo.Id, LoginName =string.Empty,LoginPassword=newPwd, IsSuccess = true, OptType = UserOptType.ModifyPassword }, true);
+
return ResponseOutput.Result(success);
}
@@ -439,6 +443,7 @@ namespace IRaCIS.Application.Services
IsFirstAdd = false
});
+ await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, CreateUserId = _userInfo.Id, LoginName = _userInfo.UserName, IsSuccess = true, OptType = UserOptType.ModifyPassword }, true);
return ResponseOutput.Result(success);
@@ -642,7 +647,7 @@ namespace IRaCIS.Application.Services
if (failCount >= maxFailures)
{
- await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, CreateUserId = Guid.Empty, LoginName = userName, IsSuccess = false, OptType = UserOptType.AccountLocked }, true);
+ await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, CreateUserId = Guid.Empty, LoginName = userName,LoginPassword=password, IsSuccess = false, OptType = UserOptType.AccountLocked }, true);
throw new BusinessValidationFailedException($"密码连续错误{maxFailures}次,当前账号已被限制登录,请等待 {lockoutMinutes} 分钟后再试。");
}
@@ -677,7 +682,7 @@ namespace IRaCIS.Application.Services
failCount++;
_cache.Set(cacheKey, failCount, TimeSpan.FromMinutes(lockoutMinutes));
- await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, CreateUserId = Guid.Empty, LoginName = userName, IsSuccess = false, OptType = UserOptType.PasswordError }, true);
+ await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, CreateUserId = Guid.Empty, LoginName = userName, LoginPassword = password, IsSuccess = false, OptType = UserOptType.AccountOrPasswordError }, true);
return ResponseOutput.NotOk(_localizer["User_CheckNameOrPw"], new LoginReturnDTO());
diff --git a/IRaCIS.Core.Domain/Management/UserLog.cs b/IRaCIS.Core.Domain/Management/UserLog.cs
index 923eb84f2..0c78d92d0 100644
--- a/IRaCIS.Core.Domain/Management/UserLog.cs
+++ b/IRaCIS.Core.Domain/Management/UserLog.cs
@@ -38,6 +38,10 @@ namespace IRaCIS.Core.Domain.Models
public bool IsSuccess { get; set; }
+
+ [JsonIgnore]
+ public User CreateUser { get; set; }
+
}
///
@@ -57,14 +61,18 @@ namespace IRaCIS.Core.Domain.Models
LoginOut = 2,
///
- /// 密码错误
+ ///账号或者密码错误
///
- PasswordError = 3,
+ AccountOrPasswordError = 3,
///
/// 账号锁定
///
- AccountLocked = 4
+ AccountLocked = 4,
+
+ ModifyPassword=5,
+
+ AdminResetPassword=6
}
}