瀏覽代碼

fix: 修复租户授权后未清除菜单权限问题

喵你个旺呀 1 年之前
父節點
當前提交
40c5b729c2

+ 2 - 1
Admin.NET/Admin.NET.Core/Service/Menu/SysMenuService.cs

@@ -263,7 +263,8 @@ public class SysMenuService : IDynamicApiController, ITransient
     /// <summary>
     /// 清除菜单和按钮缓存
     /// </summary>
-    private void DeleteMenuCache()
+    [NonAction]
+    public void DeleteMenuCache()
     {
         // _sysCacheService.RemoveByPrefixKey(CacheConst.KeyUserMenu);
         _sysCacheService.RemoveByPrefixKey(CacheConst.KeyUserButton);

+ 3 - 0
Admin.NET/Admin.NET.Core/Service/Tenant/SysTenantService.cs

@@ -431,6 +431,9 @@ public class SysTenantService : IDynamicApiController, ITransient
         await _sysTenantMenuRep.AsDeleteable().Where(u => u.TenantId == input.Id).ExecuteCommandAsync();
         var sysTenantMenuList = input.MenuIdList.Select(menuId => new SysTenantMenu { TenantId = input.Id, MenuId = menuId }).ToList();
         await _sysTenantMenuRep.InsertRangeAsync(sysTenantMenuList);
+        
+        // 清除菜单权限缓存
+        App.GetService<SysMenuService>().DeleteMenuCache();
     }
 
     /// <summary>