// PUT: api/UserRole/5 reset user role, id is userId public async Task <HandleResult> Put(string id, [FromBody] List <string> roleIds) { var command = new ResetUserRole(id, roleIds); var result = await ExecuteCommandAsync(command); if (result.IsSuccess()) { return(HandleResult.FromSuccess("设置成功")); } return(HandleResult.FromFail(result.GetErrorMessage())); }
/// <summary>重置用户角色 /// </summary> public void Handle(ICommandContext context, ResetUserRole command) { _lockService.ExecuteInLock(typeof(User).Name, () => { foreach (var roleId in command.RoleIds) { _roleService.IsEnabled(roleId); } context.Get <User>(command.AggregateRootId).ResetUserRole(command.RoleIds); }); }