|
@@ -184,23 +184,30 @@ public class UserController : BaseController
|
|
|
[HttpPut]
|
|
|
public async Task Update([FromBody] UpdateUserDto dto)
|
|
|
{
|
|
|
- var account = await _accountRepository.GetAsync(dto.Id, HttpContext.RequestAborted);
|
|
|
- CheckAccountStatus(account);
|
|
|
+ //var account = await _accountRepository.GetAsync(dto.Id, HttpContext.RequestAborted);
|
|
|
+ //CheckAccountStatus(account);
|
|
|
|
|
|
- var user = await _userRepository.GetAsync(dto.Id, HttpContext.RequestAborted);
|
|
|
+ //var user = await _userRepository.GetAsync(dto.Id, HttpContext.RequestAborted);
|
|
|
+ var user = await _userRepository.Queryable()
|
|
|
+ .Includes(d => d.Account)
|
|
|
+ .FirstAsync(d => d.Id == dto.Id, HttpContext.RequestAborted);
|
|
|
if (user is null)
|
|
|
throw UserFriendlyException.SameMessage("无效用户编号");
|
|
|
if (user.IsDeleted)
|
|
|
throw UserFriendlyException.SameMessage("账号不存在");
|
|
|
+ CheckAccountStatus(user.Account);
|
|
|
|
|
|
_mapper.Map(dto, user);
|
|
|
- _mapper.Map(dto, account);
|
|
|
- await _accountRepository.UpdateNav(account).Include(d => d.User)
|
|
|
- .ExecuteCommandAsync();
|
|
|
+ //_mapper.Map(dto, account);
|
|
|
+ //await _accountRepository.UpdateNav(account).Include(d => d.User)
|
|
|
+ // .ExecuteCommandAsync();
|
|
|
//await _userRepository.UpdateAsync(user, HttpContext.RequestAborted);
|
|
|
|
|
|
+ await _userRepository.UpdateNav(user).Include(d => d.Account)
|
|
|
+ .ExecuteCommandAsync();
|
|
|
+
|
|
|
//set roles
|
|
|
- await _accountRepository.SetAccountRolesAsync(account.Id, dto.RoleIds, HttpContext.RequestAborted);
|
|
|
+ await _accountRepository.SetAccountRolesAsync(user.Id, dto.RoleIds, HttpContext.RequestAborted);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|