105040 增加程序入口读取接口,用于自动配置权限项
This commit is contained in:
parent
ff35047431
commit
dc2f90e66b
|
|
@ -41,5 +41,11 @@ namespace LFlow.Permission.Controller
|
||||||
TotalCount = total
|
TotalCount = total
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<ApiResult<List<PermissionDto>>> GetProgPermissions()
|
||||||
|
{
|
||||||
|
var result = await service.GetPermissions();
|
||||||
|
return Success(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,5 +17,7 @@ namespace LFlow.Permission.Service
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<List<PermissionDto>> GetProgPerminssionListAsync(string progID);
|
Task<List<PermissionDto>> GetProgPerminssionListAsync(string progID);
|
||||||
|
|
||||||
|
|
||||||
|
Task<List<PermissionDto>> GetPermissions();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
using LFlow.Base.Interfaces;
|
using LFlow.Base;
|
||||||
|
using LFlow.Base.Interfaces;
|
||||||
using LFlow.Base.Utils;
|
using LFlow.Base.Utils;
|
||||||
using LFlow.Cache.Interface;
|
using LFlow.Cache.Interface;
|
||||||
using LFlow.Permission.Model;
|
using LFlow.Permission.Model;
|
||||||
using Mapster;
|
using Mapster;
|
||||||
using SqlSugar;
|
using Microsoft.AspNetCore.Mvc.Routing;
|
||||||
|
|
||||||
namespace LFlow.Permission.Service
|
namespace LFlow.Permission.Service
|
||||||
{
|
{
|
||||||
|
|
@ -64,6 +65,40 @@ namespace LFlow.Permission.Service
|
||||||
{
|
{
|
||||||
return Task.FromResult(repo.GetAll(pageIndex, pageSize, ref total).Adapt<List<PermissionDto>>());
|
return Task.FromResult(repo.GetAll(pageIndex, pageSize, ref total).Adapt<List<PermissionDto>>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Task<List<PermissionDto>> GetPermissions()
|
||||||
|
{
|
||||||
|
List<PermissionDto> 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);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取程序权限列表
|
/// 获取程序权限列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue