修复状态问题、用户中心页面查询及修改
This commit is contained in:
@@ -111,34 +111,12 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
var userId = HttpContext.GetCurrentUserEntityInfo(out _).Id;
|
||||
var data = await _iUserService.GetUserAllInfo(userId);
|
||||
|
||||
|
||||
//将后端菜单转换成前端路由,组件级别需要过滤
|
||||
List<VueRouterModel> routers = MenuEntity.RouterBuild(data.Menus.ToList());
|
||||
return Result.Success().SetData(routers);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 更新登录的用户密码
|
||||
/// </summary>
|
||||
/// <param name="updatePasswordDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
public async Task<Result> UpdatePassword(UpdatePasswordDto updatePasswordDto)
|
||||
{
|
||||
var userId = HttpContext.GetCurrentUserEntityInfo(out _).Id;
|
||||
var userEntiy = await _iUserService._repository.GetByIdAsync(userId);
|
||||
|
||||
//判断输入的老密码是否和原密码相同
|
||||
if (userEntiy.JudgePassword(updatePasswordDto.OldPassword))
|
||||
{
|
||||
userEntiy.Password = updatePasswordDto.NewPassword;
|
||||
userEntiy.BuildPassword();
|
||||
return Result.Success().SetStatus(await _iUserService._repository.UpdateAsync(userEntiy));
|
||||
}
|
||||
return Result.SuccessError("原密码错误!");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新已登录用户的用户信息
|
||||
/// </summary>
|
||||
@@ -155,5 +133,22 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
user.Id = HttpContext.GetCurrentUserEntityInfo(out _).Id;
|
||||
return Result.Success().SetStatus(await _iUserService._repository.UpdateIgnoreNullAsync(user));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自己更新密码
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
public async Task<Result> UpdatePassword(UpdatePasswordDto dto)
|
||||
{
|
||||
long userId = HttpContext.GetCurrentUserEntityInfo(out _).Id;
|
||||
|
||||
if (await _iUserService.UpdatePassword(dto, userId))
|
||||
{
|
||||
return Result.Success();
|
||||
}
|
||||
return Result.Error("更新失败!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user