Browse Source

fix bug: role menu manager

pull/204/head
cKey 5 years ago
parent
commit
8eb6812d50
  1. 6
      aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/MenuManager.cs
  2. 1
      aspnet-core/tests/LINGYUN.Platform.EntityFrameworkCore.Tests/LINGYUN/Platform/Menus/EfCoreUserMenuRepositoryTests.cs

6
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));

1
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 });

Loading…
Cancel
Save