| | |
| | | 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) |
| | |
| | | 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, |
| | |
| | | TenantId = user.TenantId, |
| | | }); |
| | | |
| | | _cacheService.AddOrUpdate(user.UserId.ToString(), token); |
| | | |
| | | content = WebResponseContent.Instance.OK(data: new { token, userName = user.UserTrueName, img = user.HeadImageUrl }); |
| | | } |
| | | else |