| | |
| | | using WIDESEA_Core.Caches; |
| | | using SqlSugar; |
| | | using ICacheService = WIDESEA_Core.Caches.ICacheService; |
| | | using Microsoft.IdentityModel.JsonWebTokens; |
| | | |
| | | namespace WIDESEA_SystemService |
| | | { |
| | |
| | | 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 |
| | | { |
| | | content = WebResponseContent.Instance.Error("è´¦å·æå¯ç é误"); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content = WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | |
| | | return content; |
| | | } |
| | | public WebResponseContent Login1(LoginInfo loginInfo) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | //BaseDal.QueryFirst(x => x.UserName == loginInfo.UserName); |
| | | |
| | | string msg = string.Empty; |
| | | |
| | | #region 临æ¶ä½¿ç¨ |
| | | try |
| | | { |
| | | loginInfo.Password = loginInfo.Password.EncryptDES(AppSecret.User); |
| | | } |
| | | catch |
| | | { |
| | | |
| | | } |
| | | #endregion |
| | | |
| | | UserInfo user = BaseDal.GetUserInfo(loginInfo.UserName, loginInfo.Password); |
| | | if (user != null) |
| | | { |
| | | object obj = _menuService.GetMenuActionList1(user.RoleId); |
| | | if (obj is not IEnumerable<object> list) |
| | | { |
| | | return WebResponseContent.Instance.Error("æ ç»å½æé"); |
| | |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | public WebResponseContent modifyUserPwd(string userName, string password) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | string message = ""; |
| | | password = password?.Trim(); |
| | | try |
| | | { |
| | | if (string.IsNullOrEmpty(password)) return WebResponseContent.Instance.Error("å¯ç ä¸è½ä¸ºç©º"); |
| | | Sys_User user = BaseDal.QueryFirst(x => x.UserName == userName); |
| | | if (user == null) return WebResponseContent.Instance.Error("ç¨æ·ä¸åå¨"); |
| | | user.UserPwd = password.EncryptDES(AppSecret.User); |
| | | BaseDal.UpdateData(user); |
| | | if (App.User.UserId == user.User_Id) |
| | | { |
| | | string token = JwtHelper.IssueJwt(new TokenModelJwt() |
| | | { |
| | | UserId = user.User_Id, |
| | | UserName = userName, |
| | | RoleId = user.Role_Id, |
| | | TenantId = user.TenantId, |
| | | }); |
| | | _cacheService.AddOrUpdate(user.User_Id.ToString(), token); |
| | | } |
| | | return content.OK("æ´æ¹æå"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | message = ex.Message; |
| | | content.Error("æå¡å¨äºç¹é®é¢,请ç¨ååè¯"); |
| | | } |
| | | return content; |
| | | } |
| | | } |
| | | } |