From 30922b809afb4bb612d85ea7602c55d1a3ee850d Mon Sep 17 00:00:00 2001 From: Elvis Date: Fri, 8 Nov 2024 14:53:15 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E8=8F=9C=E5=8D=95=E7=B1=BB?= =?UTF-8?q?=E5=88=AB=E5=AD=97=E6=AE=B5=E7=9A=84=E6=95=B0=E6=8D=AE=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E7=BB=9F=E4=B8=80=E4=BF=AE=E6=94=B9=E4=B8=BA=E6=9E=9A?= =?UTF-8?q?=E4=B8=BEMenuType?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/Magic.Core/Entity/SysMenu.cs | 9 +- backend/Magic.Core/Entity/SysRoleMenu.cs | 4 +- backend/Magic.Core/Magic.Core.xml | 19 ++- .../Service/CodeGen/CodeGenService.cs | 16 +-- .../Service/Menu/ISysMenuService.cs | 11 +- .../Magic.Core/Service/Menu/SysMenuService.cs | 121 +++++++++--------- .../Magic.Core/Service/Role/Dto/RoleParam.cs | 8 +- .../Service/Role/SysRoleMenuService.cs | 12 +- .../Magic.Core/Service/Role/SysRoleService.cs | 4 +- .../Controller/System/SysMenuController.cs | 5 +- 10 files changed, 112 insertions(+), 97 deletions(-) diff --git a/backend/Magic.Core/Entity/SysMenu.cs b/backend/Magic.Core/Entity/SysMenu.cs index f3a77d8..8b00ad3 100644 --- a/backend/Magic.Core/Entity/SysMenu.cs +++ b/backend/Magic.Core/Entity/SysMenu.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; + namespace Magic.Core.Entity; /// @@ -38,10 +39,10 @@ public class SysMenu : DEntityBase public string Code { get; set; } /// - /// 菜单类型(字典 0目录 1菜单 2按钮 3api资源)" + /// 菜单类型(字典 0目录 1菜单 2按钮 3api资源),来自枚举。 /// [SugarColumn(ColumnDescription = "菜单类型(字典 0目录 1菜单 2按钮 3api资源)")] - public int Type { get; set; } + public MenuType Type { get; set; } /// /// 图标 @@ -134,5 +135,5 @@ public class SysMenu : DEntityBase /// 多标签模式下是否开启缓存,默认开启 /// [SugarColumn(ColumnDescription = "多标签模式下是否开启缓存,默认开启")] - public bool KeepAlive { get; set; }=true; -} + public bool KeepAlive { get; set; } = true; +} \ No newline at end of file diff --git a/backend/Magic.Core/Entity/SysRoleMenu.cs b/backend/Magic.Core/Entity/SysRoleMenu.cs index 95e4dd1..d04648b 100644 --- a/backend/Magic.Core/Entity/SysRoleMenu.cs +++ b/backend/Magic.Core/Entity/SysRoleMenu.cs @@ -24,9 +24,9 @@ public class SysRoleMenu public long SysMenuId { get; set; } /// - /// 菜单类型(字典 0目录 1菜单 2按钮) + /// 菜单类型(字典 0目录 1菜单 2按钮);来自枚举。 /// [SugarColumn(ColumnDescription = "菜单类型(字典 0目录 1菜单 2按钮 3api资源)")] - public int Type { get; set; } + public MenuType Type { get; set; } } diff --git a/backend/Magic.Core/Magic.Core.xml b/backend/Magic.Core/Magic.Core.xml index ddd633e..64447b8 100644 --- a/backend/Magic.Core/Magic.Core.xml +++ b/backend/Magic.Core/Magic.Core.xml @@ -1597,7 +1597,7 @@ - 菜单类型(字典 0目录 1菜单 2按钮 3api资源)" + 菜单类型(字典 0目录 1菜单 2按钮 3api资源),来自枚举 @@ -2007,7 +2007,7 @@ - 菜单类型(字典 0目录 1菜单 2按钮) + 菜单类型(字典 0目录 1菜单 2按钮);来自枚举 @@ -6336,6 +6336,13 @@ 多标签模式下是否开启缓存,默认开启 + + + 获取系统菜单树,用于给角色授权时选择 + + + + 系统菜单服务 @@ -6426,11 +6433,11 @@ - + 获取系统菜单树,用于给角色授权时选择 - + @@ -7068,7 +7075,7 @@ - 2:菜单按钮授权 3:api资源授权 + 2:菜单按钮授权 3:api资源授权;来自枚举 @@ -7078,7 +7085,7 @@ - 2:菜单按钮授权 3:api资源授权 + 2:菜单按钮授权 3:api资源授权;来自枚举 diff --git a/backend/Magic.Core/Service/CodeGen/CodeGenService.cs b/backend/Magic.Core/Service/CodeGen/CodeGenService.cs index 7566861..8a35bf1 100644 --- a/backend/Magic.Core/Service/CodeGen/CodeGenService.cs +++ b/backend/Magic.Core/Service/CodeGen/CodeGenService.cs @@ -258,7 +258,7 @@ public class CodeGenService : ICodeGenService Pids = "[0],", Name = busName + "管理", Code = codePrefix, - Type = 1, + Type = MenuType.MENU, Icon = "robot", Router = "/" + className.ToLower(), Component = "PageView", @@ -277,7 +277,7 @@ public class CodeGenService : ICodeGenService Pids = "[0],[" + pid + "],", Name = busName + "管理", Code = codePrefix + "_mgr", - Type = 1, + Type = MenuType.MENU, Router = "/" + className.ToLower(), Component = "main/" + className + "/index", Application = application, @@ -294,7 +294,7 @@ public class CodeGenService : ICodeGenService Pids = "[0],[" + pid + "],[" + pid1 + "],", Name = busName + "分页", Code = codePrefix + "_mgr_page", - Type = 2, + Type = MenuType.BTN, Permission = className + ":page", Application = application, }; @@ -306,7 +306,7 @@ public class CodeGenService : ICodeGenService Pids = "[0],[" + pid + "],[" + pid1 + "],", Name = busName + "列表", Code = codePrefix + "_mgr_list", - Type = 2, + Type = MenuType.BTN, Permission = className + ":list", Application = application, }; @@ -318,7 +318,7 @@ public class CodeGenService : ICodeGenService Pids = "[0],[" + pid + "],[" + pid1 + "],", Name = busName + "详情", Code = codePrefix + "_mgr_detail", - Type = 2, + Type = MenuType.BTN, Permission = className + ":detail", Application = application, }; @@ -330,7 +330,7 @@ public class CodeGenService : ICodeGenService Pids = "[0],[" + pid + "],[" + pid1 + "],", Name = busName + "新增", Code = codePrefix + "_mgr_add", - Type = 2, + Type = MenuType.BTN, Permission = className + ":add", Application = application, }; @@ -342,7 +342,7 @@ public class CodeGenService : ICodeGenService Pids = "[0],[" + pid + "],[" + pid1 + "],", Name = busName + "删除", Code = codePrefix + "_mgr_delete", - Type = 2, + Type = MenuType.BTN, Permission = className + ":delete", Application = application, }; @@ -354,7 +354,7 @@ public class CodeGenService : ICodeGenService Pids = "[0],[" + pid + "],[" + pid1 + "],", Name = busName + "编辑", Code = codePrefix + "_mgr_edit", - Type = 2, + Type = MenuType.BTN, Permission = className + ":edit", Application = application, }; diff --git a/backend/Magic.Core/Service/Menu/ISysMenuService.cs b/backend/Magic.Core/Service/Menu/ISysMenuService.cs index 9bf4683..61a0cde 100644 --- a/backend/Magic.Core/Service/Menu/ISysMenuService.cs +++ b/backend/Magic.Core/Service/Menu/ISysMenuService.cs @@ -18,7 +18,14 @@ public interface ISysMenuService : ITransient Task> GetMenuTree(QueryMenuTreeInput input); Task> GetUserMenuAppCodeList(long userId); Task HasMenu(string appCode); - Task TreeForGrant(int type); + + /// + /// 获取系统菜单树,用于给角色授权时选择 + /// + /// + /// + Task TreeForGrant(MenuType type); + Task UpdateMenu(EditSysMenuInput input); Task> GetAllPermission(); -} +} \ No newline at end of file diff --git a/backend/Magic.Core/Service/Menu/SysMenuService.cs b/backend/Magic.Core/Service/Menu/SysMenuService.cs index bd47d8d..7b8fa43 100644 --- a/backend/Magic.Core/Service/Menu/SysMenuService.cs +++ b/backend/Magic.Core/Service/Menu/SysMenuService.cs @@ -1,5 +1,3 @@ - - using Furion.DependencyInjection; using Furion.DynamicApiController; using Furion.FriendlyException; @@ -7,7 +5,6 @@ using Magic.Core.Entity; using Mapster; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; - using SqlSugar; using System.Collections.Generic; using System.Linq; @@ -20,16 +17,16 @@ namespace Magic.Core.Service; /// public class SysMenuService : ISysMenuService { - private readonly SqlSugarRepository _sysMenuRep; // 菜单表仓储 + private readonly SqlSugarRepository _sysMenuRep; // 菜单表仓储 private readonly ISysCacheService _sysCacheService; private readonly ISysUserRoleService _sysUserRoleService; private readonly ISysRoleMenuService _sysRoleMenuService; public SysMenuService(SqlSugarRepository sysMenuRep, - ISysCacheService sysCacheService, - ISysUserRoleService sysUserRoleService, - ISysRoleMenuService sysRoleMenuService) + ISysCacheService sysCacheService, + ISysUserRoleService sysUserRoleService, + ISysRoleMenuService sysRoleMenuService) { _sysMenuRep = sysMenuRep; _sysCacheService = sysCacheService; @@ -52,18 +49,20 @@ public class SysMenuService : ISysMenuService var roleIdList = await _sysUserRoleService.GetUserRoleIdList(userId); var menuIdList = await _sysRoleMenuService.GetRoleMenuIdList(roleIdList); permissions = await _sysMenuRep.Where(u => menuIdList.Contains(u.Id)) - .Where(u => u.Type == (int)MenuType.BTN || u.Type == (int)MenuType.API) - .Where(u => u.Status == (int)CommonStatus.ENABLE) - .Select(u => u.Permission).ToListAsync(); + .Where(u => u.Type == MenuType.BTN || u.Type == MenuType.API) + .Where(u => u.Status == (int)CommonStatus.ENABLE) + .Select(u => u.Permission).ToListAsync(); } else { - permissions = await _sysMenuRep.Where(u => u.Type == (int)MenuType.BTN || u.Type == (int)MenuType.API) - .Where(u => u.Status == (int)CommonStatus.ENABLE) - .Select(u => u.Permission).ToListAsync(); + permissions = await _sysMenuRep.Where(u => u.Type == MenuType.BTN || u.Type == MenuType.API) + .Where(u => u.Status == (int)CommonStatus.ENABLE) + .Select(u => u.Permission).ToListAsync(); } + await _sysCacheService.SetPermission(userId, permissions); // 缓存结果 } + return permissions; } @@ -76,9 +75,9 @@ public class SysMenuService : ISysMenuService var permissions = await _sysCacheService.GetAllPermission(); // 先从缓存里面读取 if (permissions == null || permissions.Count < 1) { - permissions = await _sysMenuRep.Where(u => u.Type == (int)MenuType.BTN) - .Where(u => u.Status == (int)CommonStatus.ENABLE) - .Select(u => u.Permission).ToListAsync(); + permissions = await _sysMenuRep.Where(u => u.Type == MenuType.BTN) + .Where(u => u.Status == (int)CommonStatus.ENABLE) + .Select(u => u.Permission).ToListAsync(); await _sysCacheService.SetAllPermission(permissions); // 缓存结果 } @@ -102,12 +101,12 @@ public class SysMenuService : ISysMenuService if (UserManager.IsSuperAdmin) { sysMenuList = await _sysMenuRep - .Where(u => u.Status == (int)CommonStatus.ENABLE) - .WhereIF(!string.IsNullOrWhiteSpace(appCode), u => u.Application == appCode) - .Where(u => u.Type != (int)MenuType.BTN) - .Where(u => u.Type != (int)MenuType.API) - //.Where(u => u.Weight != (int)MenuWeight.DEFAULT_WEIGHT) - .OrderBy(u => u.Sort).ToListAsync(); + .Where(u => u.Status == (int)CommonStatus.ENABLE) + .WhereIF(!string.IsNullOrWhiteSpace(appCode), u => u.Application == appCode) + .Where(u => u.Type != MenuType.BTN) + .Where(u => u.Type != MenuType.API) + //.Where(u => u.Weight != (int)MenuWeight.DEFAULT_WEIGHT) + .OrderBy(u => u.Sort).ToListAsync(); } else { @@ -115,13 +114,14 @@ public class SysMenuService : ISysMenuService var roleIdList = await _sysUserRoleService.GetUserRoleIdList(userId); var menuIdList = await _sysRoleMenuService.GetRoleMenuIdList(roleIdList); sysMenuList = await _sysMenuRep - .Where(u => menuIdList.Contains(u.Id)) - .Where(u => u.Status == (int)CommonStatus.ENABLE) - .WhereIF(!string.IsNullOrWhiteSpace(appCode), u => u.Application == appCode) - .Where(u => u.Type != (int)MenuType.BTN) - .Where(u => u.Type != (int)MenuType.API) - .OrderBy(u => u.Sort).ToListAsync(); + .Where(u => menuIdList.Contains(u.Id)) + .Where(u => u.Status == (int)CommonStatus.ENABLE) + .WhereIF(!string.IsNullOrWhiteSpace(appCode), u => u.Application == appCode) + .Where(u => u.Type != MenuType.BTN) + .Where(u => u.Type != MenuType.API) + .OrderBy(u => u.Sort).ToListAsync(); } + // 转换成登录菜单 antDesignTreeNodes = sysMenuList.Select(u => new AntDesignTreeNode { @@ -144,6 +144,7 @@ public class SysMenuService : ISysMenuService }).ToList(); await _sysCacheService.SetMenu(userId, appCode, antDesignTreeNodes); // 缓存结果 } + return antDesignTreeNodes; } @@ -157,9 +158,9 @@ public class SysMenuService : ISysMenuService var roleIdList = await _sysUserRoleService.GetUserRoleIdList(userId); var menuIdList = await _sysRoleMenuService.GetRoleMenuIdList(roleIdList); return await _sysMenuRep.Where(u => menuIdList.Contains(u.Id)) - .Where(u=>u.Type==MenuType.MENU.GetHashCode()) - .Where(u => u.Status == (int)CommonStatus.ENABLE) - .Select(u => u.Application).ToListAsync(); + .Where(u => u.Type == MenuType.MENU) + .Where(u => u.Status == (int)CommonStatus.ENABLE) + .Select(u => u.Application).ToListAsync(); } /// @@ -170,11 +171,11 @@ public class SysMenuService : ISysMenuService public async Task List(QueryMenuListInput input) { var menus = await _sysMenuRep.AsQueryable() - .WhereIF(!string.IsNullOrWhiteSpace(input.Application), u => u.Application == input.Application.Trim()) - .WhereIF(!string.IsNullOrWhiteSpace(input.Name), u => u.Name.Contains(input.Name.Trim())) - .Where(u => u.Status == (int)CommonStatus.ENABLE).OrderBy(u => u.Sort) - .Select() - .ToListAsync(); + .WhereIF(!string.IsNullOrWhiteSpace(input.Application), u => u.Application == input.Application.Trim()) + .WhereIF(!string.IsNullOrWhiteSpace(input.Name), u => u.Name.Contains(input.Name.Trim())) + .Where(u => u.Status == (int)CommonStatus.ENABLE).OrderBy(u => u.Sort) + .Select() + .ToListAsync(); return new TreeBuildUtil().DoTreeBuild(menus); } @@ -267,7 +268,7 @@ public class SysMenuService : ISysMenuService throw Oops.Oh(ErrorCode.D1002); var childIdList = await _sysMenuRep.Where(u => u.Pids.Contains(input.Id.ToString())) - .Select(u => u.Id).ToListAsync(); + .Select(u => u.Id).ToListAsync(); childIdList.Add(input.Id); try { @@ -286,7 +287,6 @@ public class SysMenuService : ISysMenuService _sysMenuRep.CurrentRollbackTran(); throw; } - } /// @@ -311,7 +311,7 @@ public class SysMenuService : ISysMenuService // 如果是编辑,父id不能为自己的子节点 var childIdList = await _sysMenuRep.Where(u => u.Pids.Contains(input.Id.ToString())) - .Select(u => u.Id).ToListAsync(); + .Select(u => u.Id).ToListAsync(); if (childIdList.Contains(input.Pid)) throw Oops.Oh(ErrorCode.D4006); @@ -333,6 +333,7 @@ public class SysMenuService : ISysMenuService throw Oops.Oh(ErrorCode.D4007); updateSubAppsFlag = true; } + // 父节点有变化 if (input.Pid != oldMenu.Pid) updateSubPidsFlag = true; @@ -348,10 +349,7 @@ public class SysMenuService : ISysMenuService // 更新所有子节点的application if (updateSubAppsFlag) { - menuList.ForEach(u => - { - u.Application = input.Application; - }); + menuList.ForEach(u => { u.Application = input.Application; }); } // 更新所有子节点的pids @@ -400,27 +398,27 @@ public class SysMenuService : ISysMenuService public async Task> GetMenuTree(QueryMenuTreeInput input) { var menus = await _sysMenuRep.AsQueryable() - .WhereIF(!string.IsNullOrWhiteSpace(input.Application), u => u.Application == input.Application.Trim()) - .Where(u => u.Status == (int)CommonStatus.ENABLE) - .Where(u => u.Type == (int)MenuType.DIR || u.Type == (int)MenuType.MENU) - .OrderBy(u => u.Sort) - .Select(u => new MenuTreeOutput - { - Id = u.Id, - ParentId = u.Pid, - Value = u.Id.ToString(), - Title = u.Name, - Weight = u.Sort - }).ToListAsync(); + .WhereIF(!string.IsNullOrWhiteSpace(input.Application), u => u.Application == input.Application.Trim()) + .Where(u => u.Status == (int)CommonStatus.ENABLE) + .Where(u => u.Type == (int)MenuType.DIR || u.Type == MenuType.MENU) + .OrderBy(u => u.Sort) + .Select(u => new MenuTreeOutput + { + Id = u.Id, + ParentId = u.Pid, + Value = u.Id.ToString(), + Title = u.Name, + Weight = u.Sort + }).ToListAsync(); return new TreeBuildUtil().DoTreeBuild(menus); } /// /// 获取系统菜单树,用于给角色授权时选择 /// - /// + /// /// - public async Task TreeForGrant(int type) + public async Task TreeForGrant(MenuType type) { var menuIdList = new List(); if (!UserManager.IsSuperAdmin) @@ -433,8 +431,8 @@ public class SysMenuService : ISysMenuService .LeftJoin((t1, t2) => t1.Application == t2.Code) .Where(t1 => t1.Status == (int)CommonStatus.ENABLE) .WhereIF(menuIdList.Any(), t1 => menuIdList.Contains(t1.Id)) - .WhereIF(type == 2, t1 => t1.Type != 3)//传2代表授权菜单,不显示api资源 - .WhereIF(type == 3, t1 => t1.Type != 2)//传3代表授权菜单,不显示按钮 + .WhereIF(type == MenuType.BTN, t1 => t1.Type != MenuType.API) // 传 2 代表授权菜单,不显示api资源 + .WhereIF(type == MenuType.API, t1 => t1.Type != MenuType.BTN) // 传 3 代表授权菜单,不显示按钮 .OrderBy(t1 => t1.Sort).Select((t1, t2) => new MenuTreeOutput { Id = t1.Id, @@ -449,7 +447,8 @@ public class SysMenuService : ISysMenuService // 获取所有应用 var appList = menus.OrderBy(ob => ob.AppSort) - .Select(sl => new MenuTreeAppOutput { AppName = sl.AppName, AppCode = sl.AppCode }).DistinctBy(db => db.AppCode) + .Select(sl => new MenuTreeAppOutput { AppName = sl.AppName, AppCode = sl.AppCode }) + .DistinctBy(db => db.AppCode) .ToList(); return new { AppList = appList, MenuTree = new TreeBuildUtil().DoTreeBuild(menus) }; @@ -474,4 +473,4 @@ public class SysMenuService : ISysMenuService { return await GetLoginMenusAntDesign(UserManager.UserId, input.Application); } -} +} \ No newline at end of file diff --git a/backend/Magic.Core/Service/Role/Dto/RoleParam.cs b/backend/Magic.Core/Service/Role/Dto/RoleParam.cs index d82fac9..8956d2d 100644 --- a/backend/Magic.Core/Service/Role/Dto/RoleParam.cs +++ b/backend/Magic.Core/Service/Role/Dto/RoleParam.cs @@ -53,9 +53,9 @@ public class GrantRoleInput : PermissionBaseInput public long Id { get; set; } /// - /// 2:菜单按钮授权 3:api资源授权 + /// 2:菜单按钮授权 3:api资源授权;来自枚举。 /// - public int Type { get; set; } + public MenuType Type { get; set; } } public class OwnMenuInput { @@ -66,9 +66,9 @@ public class OwnMenuInput { public long Id { get; set; } /// - /// 2:菜单按钮授权 3:api资源授权 + /// 2:菜单按钮授权 3:api资源授权;来自枚举。 /// - public int Type { get; set; } + public MenuType Type { get; set; } } #endregion diff --git a/backend/Magic.Core/Service/Role/SysRoleMenuService.cs b/backend/Magic.Core/Service/Role/SysRoleMenuService.cs index 799501d..5ada65b 100644 --- a/backend/Magic.Core/Service/Role/SysRoleMenuService.cs +++ b/backend/Magic.Core/Service/Role/SysRoleMenuService.cs @@ -50,19 +50,19 @@ public class SysRoleMenuService : ISysRoleMenuService { var menuList = await _sysMenuRep .Where(m => input.GrantMenuIdList.Contains(m.Id)) - .WhereIF(input.Type == 3, m => m.Type == 3) - .WhereIF(input.Type == 2, m => m.Type != 3) + .WhereIF(input.Type == MenuType.API, m => m.Type == MenuType.API) + .WhereIF(input.Type == MenuType.BTN, m => m.Type != MenuType.API) .ToListAsync(); _sysRoleMenuRep.CurrentBeginTran(); - if (input.Type == 2) + if (input.Type == MenuType.BTN) { - await _sysRoleMenuRep.DeleteAsync(u => u.SysRoleId == input.Id && u.Type != 3); + await _sysRoleMenuRep.DeleteAsync(u => u.SysRoleId == input.Id && u.Type != MenuType.API); } - if (input.Type == 3) + if (input.Type == MenuType.API) { - await _sysRoleMenuRep.DeleteAsync(u => u.SysRoleId == input.Id && u.Type == 3); + await _sysRoleMenuRep.DeleteAsync(u => u.SysRoleId == input.Id && u.Type == MenuType.API); } var grantMenuIdList = new List(); diff --git a/backend/Magic.Core/Service/Role/SysRoleService.cs b/backend/Magic.Core/Service/Role/SysRoleService.cs index 2218944..aac29f3 100644 --- a/backend/Magic.Core/Service/Role/SysRoleService.cs +++ b/backend/Magic.Core/Service/Role/SysRoleService.cs @@ -297,8 +297,8 @@ public class SysRoleService : ISysRoleService { var menuList = await _sysRoleRep.Change().AsQueryable().LeftJoin((t1, t2) => t1.SysMenuId == t2.Id) .Where(t1 => t1.SysRoleId == input.Id) - .WhereIF(input.Type == 2, t1 => t1.Type != 3)//传2代表授权菜单,不显示api资源 - .WhereIF(input.Type == 3, t1 => t1.Type == 3)//传3代表授权菜单,不显示按钮 + .WhereIF(input.Type == MenuType.BTN, t1 => t1.Type != MenuType.API)// 传 2 代表授权菜单,不显示api资源 + .WhereIF(input.Type == MenuType.API, t1 => t1.Type == MenuType.API)// 传 3 代表授权菜单,不显示按钮 .Select((t1, t2) => new SysMenu { Id = t1.SysMenuId, Application = t2.Application }).ToListAsync(); // 拿出所有应用编码 diff --git a/backend/Magic.Web.Core/Controller/System/SysMenuController.cs b/backend/Magic.Web.Core/Controller/System/SysMenuController.cs index f5435f1..b631141 100644 --- a/backend/Magic.Web.Core/Controller/System/SysMenuController.cs +++ b/backend/Magic.Web.Core/Controller/System/SysMenuController.cs @@ -20,6 +20,7 @@ namespace Magic.Web.Core; public class SysMenuController : IDynamicApiController { private readonly ISysMenuService _service; + public SysMenuController(ISysMenuService service) { _service = service; @@ -96,7 +97,7 @@ public class SysMenuController : IDynamicApiController /// /// [HttpGet("/sysMenu/treeForGrant")] - public async Task TreeForGrant(int type=2) + public async Task TreeForGrant(MenuType type = MenuType.BTN) { return await _service.TreeForGrant(type); } @@ -112,4 +113,4 @@ public class SysMenuController : IDynamicApiController { return await _service.ChangeAppMenu(input); } -} +} \ No newline at end of file -- Gitee