From 8eb6812d507892daa6c1398053178d3c8e2d7fcb Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Mon, 22 Feb 2021 15:27:04 +0800 Subject: [PATCH] fix bug: role menu manager --- .../LINGYUN/Platform/Menus/MenuManager.cs | 6 +++--- .../LINGYUN/Platform/Menus/EfCoreUserMenuRepositoryTests.cs | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/MenuManager.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/MenuManager.cs index bbbddbd49..bb88bb5b7 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/MenuManager.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/MenuManager.cs @@ -135,7 +135,7 @@ namespace LINGYUN.Platform.Menus // 移除不存在的菜单 // TODO: 升级框架版本解决未能删除不需要菜单的问题 // userMenus.RemoveAll(x => !menuIds.Contains(x.MenuId)); - var dels = userMenus.Where(x => !menuIds.Contains(x.MenuId)).Select(x => x.Id); + var dels = userMenus.Where(x => !menuIds.Contains(x.MenuId)); if (dels.Any()) { await UserMenuRepository.DeleteManyAsync(dels); @@ -161,10 +161,10 @@ namespace LINGYUN.Platform.Menus // 移除不存在的菜单 // TODO: 升级框架版本解决未能删除不需要菜单的问题 // roleMenus.RemoveAll(x => !menuIds.Contains(x.MenuId)); - var dels = roleMenus.Where(x => !menuIds.Contains(x.MenuId)).Select(x => x.Id); + var dels = roleMenus.Where(x => !menuIds.Contains(x.MenuId)); if (dels.Any()) { - await UserMenuRepository.DeleteManyAsync(dels); + await RoleMenuRepository.DeleteManyAsync(dels); } var adds = menuIds.Where(menuId => !roleMenus.Any(x => x.MenuId == menuId)); diff --git a/aspnet-core/tests/LINGYUN.Platform.EntityFrameworkCore.Tests/LINGYUN/Platform/Menus/EfCoreUserMenuRepositoryTests.cs b/aspnet-core/tests/LINGYUN.Platform.EntityFrameworkCore.Tests/LINGYUN/Platform/Menus/EfCoreUserMenuRepositoryTests.cs index 7ec5dd49f..40a38ddc1 100644 --- a/aspnet-core/tests/LINGYUN.Platform.EntityFrameworkCore.Tests/LINGYUN/Platform/Menus/EfCoreUserMenuRepositoryTests.cs +++ b/aspnet-core/tests/LINGYUN.Platform.EntityFrameworkCore.Tests/LINGYUN/Platform/Menus/EfCoreUserMenuRepositoryTests.cs @@ -52,6 +52,7 @@ namespace LINGYUN.Platform.Menus { // 在租户范围不能查询到宿主数据 (await Repository.UserHasInMenuAsync(PlatformTestsConsts.User1Id, "admin")).ShouldBeFalse(); + (await Repository.UserHasInMenuAsync(PlatformTestsConsts.User2Id, "saas")).ShouldBeFalse(); var tenantSaasMenu = await MenuRepository.FindByNameAsync("saas"); await MenuManager.SetUserMenusAsync(PlatformTestsConsts.User2Id, new Guid[] { tenantSaasMenu.Id });