Browse Source

Add AreaAttribute to ClientProxy controller

pull/11106/head
liangshiwei 5 years ago
parent
commit
de6dfb3d9e
  1. 12
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs
  2. 10
      framework/src/Volo.Abp.Http.Client.Web/Volo/Abp/Http/Client/Web/Conventions/AbpHttpClientProxyServiceConvention.cs

12
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs

@ -80,7 +80,7 @@ namespace Volo.Abp.AspNetCore.Mvc
var setting = FindSetting(controllerType);
var moduleModel = applicationModel.GetOrAddModule(
GetRootPath(controllerType, setting),
GetRootPath(controllerType, apiDescription.ActionDescriptor, setting),
GetRemoteServiceName(controllerType, setting)
);
@ -327,7 +327,9 @@ namespace Volo.Abp.AspNetCore.Mvc
return modelNameProvider.Name ?? parameterInfo.Name;
}
private static string GetRootPath([NotNull] Type controllerType,
private static string GetRootPath(
[NotNull] Type controllerType,
[NotNull] ActionDescriptor actionDescriptor,
[CanBeNull] ConventionalControllerSetting setting)
{
if (setting != null)
@ -341,6 +343,12 @@ namespace Volo.Abp.AspNetCore.Mvc
return areaAttr.RouteValue;
}
areaAttr = actionDescriptor.EndpointMetadata.OfType<AreaAttribute>().FirstOrDefault();
if (areaAttr != null)
{
return areaAttr.RouteValue;
}
return ModuleApiDescriptionModel.DefaultRootPath;
}

10
framework/src/Volo.Abp.Http.Client.Web/Volo/Abp/Http/Client/Web/Conventions/AbpHttpClientProxyServiceConvention.cs

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using Microsoft.AspNetCore.Mvc;
@ -50,6 +51,15 @@ namespace Volo.Abp.Http.Client.Web.Conventions
{
controller.ControllerName = controller.ControllerName.RemovePostFix("ClientProxy");
var moduleApiDescription = FindModuleApiDescriptionModel(controller);
if (moduleApiDescription != null && !moduleApiDescription.RootPath.IsNullOrWhiteSpace())
{
var selector = controller.Selectors.FirstOrDefault();
selector?.EndpointMetadata.Add(new AreaAttribute(moduleApiDescription.RootPath));
controller.RouteValues.Add(new KeyValuePair<string, string>("area", moduleApiDescription.RootPath));
}
var controllerApiDescription = FindControllerApiDescriptionModel(controller);
if (controllerApiDescription != null &&
!controllerApiDescription.ControllerGroupName.IsNullOrWhiteSpace())

Loading…
Cancel
Save