From 0d07b90fd906e52ce486484aa53a6850983b1325 Mon Sep 17 00:00:00 2001 From: hutongqing <hutongqing@hnkhzn.com> Date: 星期二, 15 十月 2024 14:21:57 +0800 Subject: [PATCH] 更新 --- WIDESEAWCS_Server/WIDESEAWCS_SystemServices/Sys_UserService.cs | 21 ++++++++++++++++++++- 1 files changed, 20 insertions(+), 1 deletions(-) diff --git a/WIDESEAWCS_Server/WIDESEAWCS_SystemServices/Sys_UserService.cs b/WIDESEAWCS_Server/WIDESEAWCS_SystemServices/Sys_UserService.cs index 8ccfb3e..2c740c4 100644 --- a/WIDESEAWCS_Server/WIDESEAWCS_SystemServices/Sys_UserService.cs +++ b/WIDESEAWCS_Server/WIDESEAWCS_SystemServices/Sys_UserService.cs @@ -10,15 +10,20 @@ using WIDESEAWCS_ISystemRepository; using WIDESEAWCS_Core.BaseRepository; using System.Net; +using WIDESEAWCS_Core.Caches; namespace WIDESEAWCS_SystemServices { public class Sys_UserService : ServiceBase<Sys_User, ISys_UserRepository>, ISys_UserService { private readonly IUnitOfWorkManage _unitOfWorkManage; - public Sys_UserService(ISys_UserRepository repository, IUnitOfWorkManage unitOfWorkManage) : base(repository) + private readonly ICacheService _cacheService; + private readonly ISys_MenuService _menuService; + public Sys_UserService(ISys_UserRepository repository, IUnitOfWorkManage unitOfWorkManage, ICacheService cacheService, ISys_MenuService menuService) : base(repository) { _unitOfWorkManage = unitOfWorkManage; + _cacheService = cacheService; + _menuService = menuService; } public WebResponseContent Login(LoginInfo loginInfo) @@ -44,12 +49,26 @@ UserInfo user = BaseDal.GetUserInfo(loginInfo.UserName, loginInfo.Password); if (user != null) { + object obj = _menuService.GetMenuActionList(user.RoleId); + if (obj is not IEnumerable<object> list) + { + return WebResponseContent.Instance.Error("鏃犵櫥褰曟潈闄�"); + } + if (!list.Any()) + { + return WebResponseContent.Instance.Error("鏃犵櫥褰曟潈闄�"); + } + string token = JwtHelper.IssueJwt(new TokenModelJwt() { UserId = user.UserId, RoleId = user.RoleId, + UserName = user.UserName, + TenantId = user.TenantId, }); + _cacheService.AddOrUpdate(user.UserId.ToString(), token); + content = WebResponseContent.Instance.OK(data: new { token, userName = user.UserTrueName, img = user.HeadImageUrl }); } else -- Gitblit v1.9.3