Browse Source
Merge pull request #204 from colinin/4.2
fix bug: role menu manager
pull/252/head
cKey
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
4 additions and
3 deletions
-
aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/MenuManager.cs
-
aspnet-core/tests/LINGYUN.Platform.EntityFrameworkCore.Tests/LINGYUN/Platform/Menus/EfCoreUserMenuRepositoryTests.cs
|
|
@ -135,7 +135,7 @@ namespace LINGYUN.Platform.Menus |
|
|
// 移除不存在的菜单
|
|
|
// 移除不存在的菜单
|
|
|
// TODO: 升级框架版本解决未能删除不需要菜单的问题
|
|
|
// TODO: 升级框架版本解决未能删除不需要菜单的问题
|
|
|
// userMenus.RemoveAll(x => !menuIds.Contains(x.MenuId));
|
|
|
// 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()) |
|
|
if (dels.Any()) |
|
|
{ |
|
|
{ |
|
|
await UserMenuRepository.DeleteManyAsync(dels); |
|
|
await UserMenuRepository.DeleteManyAsync(dels); |
|
|
@ -161,10 +161,10 @@ namespace LINGYUN.Platform.Menus |
|
|
// 移除不存在的菜单
|
|
|
// 移除不存在的菜单
|
|
|
// TODO: 升级框架版本解决未能删除不需要菜单的问题
|
|
|
// TODO: 升级框架版本解决未能删除不需要菜单的问题
|
|
|
// roleMenus.RemoveAll(x => !menuIds.Contains(x.MenuId));
|
|
|
// 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()) |
|
|
if (dels.Any()) |
|
|
{ |
|
|
{ |
|
|
await UserMenuRepository.DeleteManyAsync(dels); |
|
|
await RoleMenuRepository.DeleteManyAsync(dels); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var adds = menuIds.Where(menuId => !roleMenus.Any(x => x.MenuId == menuId)); |
|
|
var adds = menuIds.Where(menuId => !roleMenus.Any(x => x.MenuId == menuId)); |
|
|
|
|
|
@ -52,6 +52,7 @@ namespace LINGYUN.Platform.Menus |
|
|
{ |
|
|
{ |
|
|
// 在租户范围不能查询到宿主数据
|
|
|
// 在租户范围不能查询到宿主数据
|
|
|
(await Repository.UserHasInMenuAsync(PlatformTestsConsts.User1Id, "admin")).ShouldBeFalse(); |
|
|
(await Repository.UserHasInMenuAsync(PlatformTestsConsts.User1Id, "admin")).ShouldBeFalse(); |
|
|
|
|
|
(await Repository.UserHasInMenuAsync(PlatformTestsConsts.User2Id, "saas")).ShouldBeFalse(); |
|
|
|
|
|
|
|
|
var tenantSaasMenu = await MenuRepository.FindByNameAsync("saas"); |
|
|
var tenantSaasMenu = await MenuRepository.FindByNameAsync("saas"); |
|
|
await MenuManager.SetUserMenusAsync(PlatformTestsConsts.User2Id, new Guid[] { tenantSaasMenu.Id }); |
|
|
await MenuManager.SetUserMenusAsync(PlatformTestsConsts.User2Id, new Guid[] { tenantSaasMenu.Id }); |
|
|
|