重置密码功能

This commit is contained in:
chenchun
2022-09-11 13:16:24 +08:00
parent 0cd3bea6bd
commit 909bdf60e7
5 changed files with 31 additions and 3 deletions

View File

@@ -115,5 +115,11 @@ namespace Yi.Framework.ApiMicroservice.Controllers
{
return Result.Success().SetStatus(await _iUserService.AddInfo(userDto));
}
[HttpPut]
public async Task<Result> RestPassword(UserEntity user)
{
return Result.Success().SetStatus(await _iUserService.RestPassword(user.Id, user.Password));
}
}
}

View File

@@ -98,5 +98,13 @@ namespace Yi.Framework.Interface
/// <param name="userDto"></param>
/// <returns></returns>
Task<bool> AddInfo(UserInfoDto userDto);
/// <summary>
/// 重置密码
/// </summary>
/// <param name="userId"></param>
/// <param name="password"></param>
/// <returns></returns>
Task<bool> RestPassword(long userId,string password );
}
}

View File

@@ -235,5 +235,17 @@ namespace Yi.Framework.Service
var res2 = await GiveUserSetRole(new List<long> { res1 }, userDto.RoleIds);
return !0.Equals(res1) && res2;
}
public async Task<bool> RestPassword(long userId, string password)
{
var user = new UserEntity();
user.Id = userId;
user.Password = password;
user.BuildPassword();
return await _repository.UpdateIgnoreNullAsync(user);
}
}
}