feat 用户解锁

This commit is contained in:
2025-05-13 09:57:22 +08:00
parent c2b97024dc
commit 2a45521ed7
3 changed files with 24 additions and 0 deletions

View File

@@ -108,4 +108,14 @@ public class UsersController : ControllerBase
{
await _userService.ResetPasswordAsync(request);
}
/// <summary>
/// 用户解锁
/// </summary>
/// <param name="userId"></param>
[HttpPost("unlock/{userId:int}")]
public async Task UnlockAsync(int userId)
{
await _userService.UnlockAsync(userId);
}
}

View File

@@ -24,4 +24,7 @@ public interface IUserService : IScopeDependency
Task ResetLoginTenantAsync(UserResetLoginTenantRequest request);
Task ResetPasswordAsync(UserResetPasswordRequest request);
Task UnlockAsync(int userId);
}

View File

@@ -100,6 +100,17 @@ public class UserService : IUserService
var user = await _identityDbContext.Queryable<UserEntity>().Where(x => x.Id == request.UserId).Select<UserResponse>().FirstAsync();
}
public async Task UnlockAsync(int userId)
{
var user = await _identityDbContext.Queryable<UserEntity>().SingleAsync(x => x.Id == userId);
user.ThrowIfNull("用户不存在");
user.LockoutEnd = null;
await _identityDbContext.UpdateAsync(user);
}
public async Task<List<UserResponse>> GetUserByIdsAsync(List<int> ids)
{
return await _identityDbContext.Queryable<UserEntity>()