public virtual Task UpdateAsync(string providerName, string providerKey, UpdateMenuGrantsDto input)
 {
     return(_menuGrantAppService.UpdateAsync(providerName, providerKey, input));
 }
        public virtual async Task UpdateAsync(string providerName, string providerKey, UpdateMenuGrantsDto input)
        {
            await CheckProviderPolicy(providerName);

            foreach (var grantDto in input.Menus)
            {
                await _menuManager.SetAsync(grantDto.Id, providerName, providerKey, grantDto.IsGranted);
            }

            var permissions          = _menuManager.GetPermissions(providerName);
            var updatePermissionDtos = permissions
                                       .Select(x =>
            {
                var menuDto = input.Menus.FirstOrDefault(y => y.PermissionKey == x.Name);
                var dto     = new UpdatePermissionDto
                {
                    Name      = x.Name,
                    IsGranted = menuDto?.IsGranted ?? false     // 默认不给予授权,如果菜单与权限绑定,则以菜单的授权为主。
                };

                return(dto);
            })
                                       .ToArray();

            await _permissionAppService.UpdateAsync(
                providerName,
                providerKey,
                new UpdatePermissionsDto
            {
                Permissions = updatePermissionDtos
            }
                );
        }