From 2a45521ed7f5045b4ab2caf41cb5aa0eb034c072 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Tue, 13 May 2025 09:57:22 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E7=94=A8=E6=88=B7=E8=A7=A3=E9=94=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Src/Dlhis.Sys/Identity/Controllers/UsersController.cs | 10 ++++++++++ Src/Dlhis.Sys/Identity/Services/IUserService.cs | 3 +++ .../Identity/Services/Implements/UserService.cs | 11 +++++++++++ 3 files changed, 24 insertions(+) diff --git a/Src/Dlhis.Sys/Identity/Controllers/UsersController.cs b/Src/Dlhis.Sys/Identity/Controllers/UsersController.cs index a6076353..69e85c13 100644 --- a/Src/Dlhis.Sys/Identity/Controllers/UsersController.cs +++ b/Src/Dlhis.Sys/Identity/Controllers/UsersController.cs @@ -108,4 +108,14 @@ public class UsersController : ControllerBase { await _userService.ResetPasswordAsync(request); } + + /// + /// 用户解锁 + /// + /// + [HttpPost("unlock/{userId:int}")] + public async Task UnlockAsync(int userId) + { + await _userService.UnlockAsync(userId); + } } \ No newline at end of file diff --git a/Src/Dlhis.Sys/Identity/Services/IUserService.cs b/Src/Dlhis.Sys/Identity/Services/IUserService.cs index 6f114ba3..15da55fe 100644 --- a/Src/Dlhis.Sys/Identity/Services/IUserService.cs +++ b/Src/Dlhis.Sys/Identity/Services/IUserService.cs @@ -24,4 +24,7 @@ public interface IUserService : IScopeDependency Task ResetLoginTenantAsync(UserResetLoginTenantRequest request); Task ResetPasswordAsync(UserResetPasswordRequest request); + + + Task UnlockAsync(int userId); } \ No newline at end of file diff --git a/Src/Dlhis.Sys/Identity/Services/Implements/UserService.cs b/Src/Dlhis.Sys/Identity/Services/Implements/UserService.cs index 659af492..cdc40d3e 100644 --- a/Src/Dlhis.Sys/Identity/Services/Implements/UserService.cs +++ b/Src/Dlhis.Sys/Identity/Services/Implements/UserService.cs @@ -100,6 +100,17 @@ public class UserService : IUserService var user = await _identityDbContext.Queryable().Where(x => x.Id == request.UserId).Select().FirstAsync(); } + + public async Task UnlockAsync(int userId) + { + var user = await _identityDbContext.Queryable().SingleAsync(x => x.Id == userId); + user.ThrowIfNull("用户不存在"); + + user.LockoutEnd = null; + + await _identityDbContext.UpdateAsync(user); + } + public async Task> GetUserByIdsAsync(List ids) { return await _identityDbContext.Queryable()