Admin.Core/src/platform/ZhonTai.Admin/Core/Conventions/ApiGroupConvention.cs
(完整代码) 1KBusing Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ApplicationModels;
using ZhonTai.DynamicApi.Attributes;
namespace ZhonTai.Admin.Core.Conventions;
/// <summary>
/// Api分组约定
/// </summary>
public class ApiGroupConvention : IControllerModelConvention
{
public void Apply(ControllerModel controller)
{
if (controller.Attributes?.Count > 0)
{
foreach (var attribute in controller.Attributes)
{
if (attribute is AreaAttribute area)
{
if (controller.ApiExplorer.GroupName.IsNull())
{
controller.ApiExplorer.GroupName = area.RouteValue?.ToLower();
}
break;
}
else if (attribute is DynamicApiAttribute dynamicApi)
{
if (controller.ApiExplorer.GroupName.IsNull())
{
controller.ApiExplorer.GroupName = dynamicApi.Area?.ToLower();
}
break;
}
}
}
}
}
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
