diff --git a/LFlow.Permission/Controller/PermissionController.cs b/LFlow.Permission/Controller/PermissionController.cs index 06d4099..dcc2c96 100644 --- a/LFlow.Permission/Controller/PermissionController.cs +++ b/LFlow.Permission/Controller/PermissionController.cs @@ -41,5 +41,11 @@ namespace LFlow.Permission.Controller TotalCount = total }; } + [HttpGet] + public async Task>> GetProgPermissions() + { + var result = await service.GetPermissions(); + return Success(result); + } } } diff --git a/LFlow.Permission/Service/IPermissionService.cs b/LFlow.Permission/Service/IPermissionService.cs index 0eb7294..650a248 100644 --- a/LFlow.Permission/Service/IPermissionService.cs +++ b/LFlow.Permission/Service/IPermissionService.cs @@ -17,5 +17,7 @@ namespace LFlow.Permission.Service /// Task> GetProgPerminssionListAsync(string progID); + + Task> GetPermissions(); } } diff --git a/LFlow.Permission/Service/PermissionService.cs b/LFlow.Permission/Service/PermissionService.cs index 9b98a73..685d82c 100644 --- a/LFlow.Permission/Service/PermissionService.cs +++ b/LFlow.Permission/Service/PermissionService.cs @@ -1,9 +1,10 @@ -using LFlow.Base.Interfaces; +using LFlow.Base; +using LFlow.Base.Interfaces; using LFlow.Base.Utils; using LFlow.Cache.Interface; using LFlow.Permission.Model; using Mapster; -using SqlSugar; +using Microsoft.AspNetCore.Mvc.Routing; namespace LFlow.Permission.Service { @@ -64,6 +65,40 @@ namespace LFlow.Permission.Service { return Task.FromResult(repo.GetAll(pageIndex, pageSize, ref total).Adapt>()); } + + public Task> GetPermissions() + { + List permissions = []; + App.SubServiceAssembly.ForEach(service => + { + var types = service.GetTypes(); + foreach (var item in types.Where(type => type.IsSubclassOf(typeof(BaseController)))) + { + var progName = item.Name.Replace("Controller", ""); + foreach (var method in item.GetMethods()) + { + var attrs = method.CustomAttributes.Where(attr => + { + return attr.AttributeType.IsSubclassOf(typeof(HttpMethodAttribute)); + }); + if (attrs != null && attrs.Count() > 0) + { + var permission = new PermissionDto + { + //ProgID = progName, + PermissionAction = method.Name, + PermissionProgID = progName + }; + permissions.Add(permission); + } + + } + } + + }); + return Task.FromResult(permissions); + } + /// /// 获取程序权限列表 ///