diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs index 2e6e70ed..8c9a7c24 100644 --- a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs +++ b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs @@ -109,36 +109,41 @@ namespace Yi.Framework.ApiMicroservice.Controllers [HttpPut] public async Task ChangePassword(ChangePwdDto pwdDto) { - var user_data = await _userService.GetUserInfoById(pwdDto.user.id); - + var uid= pwdDto.user.id; + var user_data = await _userService.GetUserById(uid); + string msg = "修改成功"; if (pwdDto.newPassword != null) { if (user_data.password == pwdDto.user.password) { + user_data.password = pwdDto.newPassword; user_data.phone = pwdDto.user.phone; user_data.introduction = pwdDto.user.introduction; user_data.email = pwdDto.user.email; user_data.age = pwdDto.user.age; user_data.address = pwdDto.user.address; - user_data.nick = pwdDto.user.nick; await _userService.UpdateAsync(user_data); user_data.password = null; - return Result.Success().SetData(user_data); + return Result.Success(msg).SetData(user_data); + } + else + { + msg = "密码错误"; + return Result.Error(msg); } } - + user_data.phone = pwdDto.user.phone; user_data.introduction = pwdDto.user.introduction; user_data.email = pwdDto.user.email; user_data.age = pwdDto.user.age; user_data.address = pwdDto.user.address; - user_data.is_delete = pwdDto.user.is_delete; user_data.nick = pwdDto.user.nick; await _userService.UpdateAsync(user_data); user_data.password = null; - return Result.Success().SetData(user_data); + return Result.Success(msg).SetData(user_data); } } } \ No newline at end of file diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/YIDB.db-shm b/Yi.Framework/Yi.Framework.ApiMicroservice/YIDB.db-shm new file mode 100644 index 00000000..1e3a6416 Binary files /dev/null and b/Yi.Framework/Yi.Framework.ApiMicroservice/YIDB.db-shm differ diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/YIDB.db-wal b/Yi.Framework/Yi.Framework.ApiMicroservice/YIDB.db-wal new file mode 100644 index 00000000..390fa52f Binary files /dev/null and b/Yi.Framework/Yi.Framework.ApiMicroservice/YIDB.db-wal differ diff --git a/Yi.Framework/Yi.Framework.Interface/IUserService.cs b/Yi.Framework/Yi.Framework.Interface/IUserService.cs index 508cf1f0..a8aba8b3 100644 --- a/Yi.Framework/Yi.Framework.Interface/IUserService.cs +++ b/Yi.Framework/Yi.Framework.Interface/IUserService.cs @@ -69,5 +69,6 @@ namespace Yi.Framework.Interface /// /// Task GetUserInfoById(int user_id); + Task GetUserById(int user_id); } } diff --git a/Yi.Framework/Yi.Framework.Service/UserService.cs b/Yi.Framework/Yi.Framework.Service/UserService.cs index 57477e71..66b2b1b7 100644 --- a/Yi.Framework/Yi.Framework.Service/UserService.cs +++ b/Yi.Framework/Yi.Framework.Service/UserService.cs @@ -126,9 +126,17 @@ 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.password = null; + //user_data.password = null; user_data.roles.ToList().ForEach(u => u.users = null); return user_data; } - } + public async Task GetUserById(int user_id) + { + 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; + } + } }