From 7f5cba11b74ce63886537b231108731286c72aa5 Mon Sep 17 00:00:00 2001 From: lzw <605106923@qq.com> Date: Wed, 20 Oct 2021 16:23:57 +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 | 28 +++++++++++++++---- .../Yi.Framework.Service/UserService.cs | 1 + 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs index 3215b437..c33b0d52 100644 --- a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs +++ b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs @@ -101,17 +101,33 @@ 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) + if (pwdDto.newPassword != null) { - user_data.password = pwdDto.newPassword; - await _userService.UpdateAsync(user_data); - return Result.Success(); + var user_data = await _userService.GetEntityById(pwdDto.id); + if (user_data.password == pwdDto.password) + { + user_data.password = pwdDto.newPassword; + user_data.phone = pwdDto.phone; + user_data.introduction = pwdDto.introduction; + user_data.email = pwdDto.email; + user_data.age = pwdDto.age; + user_data.address = pwdDto.address; + user_data.is_delete = pwdDto.is_delete; + user_data.nick = pwdDto.nick; + await _userService.UpdateAsync(user_data); + user_data.password = null; + return Result.Success().SetData(user_data); + } } + return Result.Error(); } } diff --git a/Yi.Framework/Yi.Framework.Service/UserService.cs b/Yi.Framework/Yi.Framework.Service/UserService.cs index 4d97c160..11226da2 100644 --- a/Yi.Framework/Yi.Framework.Service/UserService.cs +++ b/Yi.Framework/Yi.Framework.Service/UserService.cs @@ -126,6 +126,7 @@ namespace Yi.Framework.Service { var user_data=await _Db.Set().Include(u=>u.roles) .Where(u => u.id == user_id && u.is_delete == (short)Common.Enum.DelFlagEnum.Normal).FirstOrDefaultAsync(); + user_data.roles.ToList().ForEach(u => u.users = null); return user_data; } }