From 135b9148b3c8a58e0f4d09411af906f5a9664122 Mon Sep 17 00:00:00 2001 From: lzw <605106923@qq.com> Date: Mon, 18 Oct 2021 21:54:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BF=AE=E6=94=B9=E5=AF=86?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/AccountController.cs | 14 +++++++++++++ .../Yi.Framework.DTOModel/ChangePwdDto.cs | 2 +- .../Yi.Framework.Interface/IUserService.cs | 4 +--- .../Yi.Framework.Service/UserService.cs | 20 +++++++++---------- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs index 4c67064c..3215b437 100644 --- a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs +++ b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs @@ -8,6 +8,7 @@ using Yi.Framework.Common; using Yi.Framework.Common.Helper; using Yi.Framework.Common.Models; using Yi.Framework.Core; +using Yi.Framework.DTOModel; using Yi.Framework.Interface; using Yi.Framework.Model.Models; @@ -100,5 +101,18 @@ namespace Yi.Framework.ApiMicroservice.Controllers } // 邮箱和验证码都要被记住,然后注册时候比对邮箱和验证码是不是都和现在生成的一样 } + [HttpPut] + + public async Task ChangePassword(ChangePwdDto pwdDto) + { + var user_data = await _userService.GetEntityById(pwdDto.id); + if (user_data.password == pwdDto.newPassword) + { + user_data.password = pwdDto.newPassword; + await _userService.UpdateAsync(user_data); + return Result.Success(); + } + return Result.Error(); + } } } \ No newline at end of file diff --git a/Yi.Framework/Yi.Framework.DTOModel/ChangePwdDto.cs b/Yi.Framework/Yi.Framework.DTOModel/ChangePwdDto.cs index 106d0681..3ee64bb3 100644 --- a/Yi.Framework/Yi.Framework.DTOModel/ChangePwdDto.cs +++ b/Yi.Framework/Yi.Framework.DTOModel/ChangePwdDto.cs @@ -9,6 +9,6 @@ namespace Yi.Framework.DTOModel { public class ChangePwdDto:user { - public string oldPassword { get; set; } + public string newPassword { get; set; } } } diff --git a/Yi.Framework/Yi.Framework.Interface/IUserService.cs b/Yi.Framework/Yi.Framework.Interface/IUserService.cs index 1e1bad92..8a60b2c9 100644 --- a/Yi.Framework/Yi.Framework.Interface/IUserService.cs +++ b/Yi.Framework/Yi.Framework.Interface/IUserService.cs @@ -62,8 +62,6 @@ namespace Yi.Framework.Interface /// /// /// - Task>> GetMenuByUser(user _user); - - + Task> GetMenuByUser(user _user); } } diff --git a/Yi.Framework/Yi.Framework.Service/UserService.cs b/Yi.Framework/Yi.Framework.Service/UserService.cs index 9301fd6c..b41af503 100644 --- a/Yi.Framework/Yi.Framework.Service/UserService.cs +++ b/Yi.Framework/Yi.Framework.Service/UserService.cs @@ -99,20 +99,20 @@ namespace Yi.Framework.Service return await UpdateListAsync(user_data); } - public async Task >> GetMenuByUser(user _user) + public async Task > GetMenuByUser(user _user) { var user_data =await _Db.Set().Include(u => u.roles).ThenInclude(u => u.menus) .Where(u => u.id == _user.id && u.is_delete == (short)Common.Enum.DelFlagEnum.Normal).FirstOrDefaultAsync(); - var roleList= user_data.roles.ToList(); - var menuList = new List>(); - foreach (var role in roleList) + var role_data= user_data.roles.ToList(); + List menu_data = new (); + foreach (var role in role_data) { - var menu= await _roleService.GetMenusByRole(role); - menu.ForEach(u => u.roles = null); - menuList.Add(menu); - } - return menuList; + var menu = await _roleService.GetMenusByRole(role); + menu.ForEach(u=>u.roles=null); + menu_data = menu_data.Concat(menu).OrderByDescending(u=>u.sort).ToList(); + } + return menu_data; } - + } }