105040 Add 用户登录后缓存

This commit is contained in:
lihanbo 2024-10-31 17:49:25 +08:00
parent 8931360620
commit e36444b9b8
1 changed files with 3 additions and 1 deletions

View File

@ -1,5 +1,6 @@
using LFlow.Base.Interfaces;
using LFlow.Base.Utils;
using LFlow.Cache.Interface;
using LFlow.UserManagement.Model;
using LFlow.UserManagement.Util;
@ -8,7 +9,7 @@ namespace LFlow.UserManagement.Service
/// <summary>
/// 在线管理服务
/// </summary>
public class UserManagementService(IRepo<UserModel, string> repo) : IUserManagementService
public class UserManagementService(IRepo<UserModel, string> repo, ISelfCache cacher) : IUserManagementService
{
public UserDto? Login(UserDto user)
{
@ -26,6 +27,7 @@ namespace LFlow.UserManagement.Service
}
var loginedUser = repo.Get(userModel.FirstOrDefault());
loginedUser.UserPassword = "";
cacher.SetAsync(loginedUser.ID, loginedUser, TimeSpan.FromHours(2));
return loginedUser.MapTo<UserDto>();
}