WCS
dengjunjie
2024-10-14 8acdbcfbe06832f35963201c5bacd86dc3e7092d
´úÂë¹ÜÀí/WCS/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,6 +49,16 @@
                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,
@@ -52,6 +67,8 @@
                        TenantId = user.TenantId,
                    });
                    _cacheService.AddOrUpdate(user.UserId.ToString(), token);
                    content = WebResponseContent.Instance.OK(data: new { token, userName = user.UserTrueName, img = user.HeadImageUrl });
                }
                else