From 0767c8441b7962c1c82854c516518aacc19a4ab3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 19 Sep 2017 15:59:59 +0300 Subject: [PATCH] Rename modulename to RootPath. --- .../AbpDesk.Web.Mvc/appsettings.Staging.json | 6 +-- .../AspNetCore/Mvc/AbpAppServiceConvention.cs | 53 +++++++------------ .../Mvc/AbpControllerAssemblySetting.cs | 6 +-- .../Mvc/AppServiceControllerOptions.cs | 4 +- .../AspNetCoreApiDescriptionModelProvider.cs | 12 ++--- .../Mvc/UrlActionNameNormalizerContext.cs | 6 +-- .../ApplicationApiDescriptionModel.cs | 12 ++--- .../Modeling/ModuleApiDescriptionModel.cs | 12 ++--- .../JQuery/JQueryProxyScriptGenerator.cs | 10 ++-- .../AbpIdentityHttpApiClientModule.cs | 4 +- 10 files changed, 56 insertions(+), 69 deletions(-) diff --git a/src/AbpDesk/AbpDesk.Web.Mvc/appsettings.Staging.json b/src/AbpDesk/AbpDesk.Web.Mvc/appsettings.Staging.json index 7e25fee278..c84ff7f89f 100644 --- a/src/AbpDesk/AbpDesk.Web.Mvc/appsettings.Staging.json +++ b/src/AbpDesk/AbpDesk.Web.Mvc/appsettings.Staging.json @@ -3,9 +3,9 @@ "Default": "Server=10.0.75.1;Database=AbpDesk;User=sa;Password=123qwe;", "AbpDeskMongoBlog": "mongodb://outputs_mongodb_1:27017|AbpDeskBlog" }, - "AbpIdentity": { - "HttpApiClient": { - "ApiUrlBase": "http://outputs_abpidentity_httpapihost_1/" + "RemoteServices": { + "AbpIdentity": { + "BaseUrl": "http://outputs_abpidentity_httpapihost_1/" } } } \ No newline at end of file diff --git a/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAppServiceConvention.cs b/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAppServiceConvention.cs index 54f556bcfc..e8b009949a 100644 --- a/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAppServiceConvention.cs +++ b/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAppServiceConvention.cs @@ -55,21 +55,6 @@ namespace Volo.Abp.AspNetCore.Mvc } } - protected virtual void ConfigureArea(ControllerModel controller, [CanBeNull] AbpControllerAssemblySetting configuration) - { - if (configuration == null) - { - return; - } - - if (controller.RouteValues.ContainsKey("area")) - { - return; - } - - controller.RouteValues["area"] = configuration.ModuleName; - } - protected virtual void ConfigureRemoteService(ControllerModel controller, [CanBeNull] AbpControllerAssemblySetting configuration) { ConfigureApiExplorer(controller); @@ -189,35 +174,35 @@ namespace Volo.Abp.AspNetCore.Mvc return; } - var moduleName = GetModuleNameOrDefault(controller.ControllerType.AsType()); + var rootPath = GetRootPathOrDefault(controller.ControllerType.AsType()); foreach (var action in controller.Actions) { - ConfigureSelector(moduleName, controller.ControllerName, action, configuration); + ConfigureSelector(rootPath, controller.ControllerName, action, configuration); } } - protected virtual void ConfigureSelector(string moduleName, string controllerName, ActionModel action, [CanBeNull] AbpControllerAssemblySetting configuration) + protected virtual void ConfigureSelector(string rootPath, string controllerName, ActionModel action, [CanBeNull] AbpControllerAssemblySetting configuration) { RemoveEmptySelectors(action.Selectors); if (!action.Selectors.Any()) { - AddAbpServiceSelector(moduleName, controllerName, action, configuration); + AddAbpServiceSelector(rootPath, controllerName, action, configuration); } else { - NormalizeSelectorRoutes(moduleName, controllerName, action); + NormalizeSelectorRoutes(rootPath, controllerName, action); } } - protected virtual void AddAbpServiceSelector(string moduleName, string controllerName, ActionModel action, [CanBeNull] AbpControllerAssemblySetting configuration) + protected virtual void AddAbpServiceSelector(string rootPath, string controllerName, ActionModel action, [CanBeNull] AbpControllerAssemblySetting configuration) { var httpMethod = SelectHttpMethod(action, configuration); var abpServiceSelectorModel = new SelectorModel { - AttributeRouteModel = CreateAbpServiceAttributeRouteModel(moduleName, controllerName, action, httpMethod), + AttributeRouteModel = CreateAbpServiceAttributeRouteModel(rootPath, controllerName, action, httpMethod), ActionConstraints = { new HttpMethodActionConstraint(new[] { httpMethod }) } }; @@ -229,22 +214,22 @@ namespace Volo.Abp.AspNetCore.Mvc return HttpMethodHelper.GetConventionalVerbForMethodName(action.ActionName); } - protected virtual void NormalizeSelectorRoutes(string moduleName, string controllerName, ActionModel action) + protected virtual void NormalizeSelectorRoutes(string rootPath, string controllerName, ActionModel action) { foreach (var selector in action.Selectors) { var httpMethod = selector.ActionConstraints.OfType().FirstOrDefault()?.HttpMethods?.FirstOrDefault(); if (selector.AttributeRouteModel == null) { - selector.AttributeRouteModel = CreateAbpServiceAttributeRouteModel(moduleName, controllerName, action, httpMethod); + selector.AttributeRouteModel = CreateAbpServiceAttributeRouteModel(rootPath, controllerName, action, httpMethod); } } } - protected virtual string GetModuleNameOrDefault(Type controllerType) + protected virtual string GetRootPathOrDefault(Type controllerType) { - return GetControllerSettingOrNull(controllerType)?.ModuleName ?? - ModuleApiDescriptionModel.DefaultModuleName; + return GetControllerSettingOrNull(controllerType)?.RootPath ?? + ModuleApiDescriptionModel.DefaultRootPath; } [CanBeNull] @@ -253,16 +238,16 @@ namespace Volo.Abp.AspNetCore.Mvc return _options.AppServiceControllers.ControllerAssemblySettings.GetSettingOrNull(controllerType); } - protected virtual AttributeRouteModel CreateAbpServiceAttributeRouteModel(string moduleName, string controllerName, ActionModel action, string httpMethod) + protected virtual AttributeRouteModel CreateAbpServiceAttributeRouteModel(string rootPath, string controllerName, ActionModel action, string httpMethod) { - var url = CalculateUrl(moduleName, controllerName, action, httpMethod); + var url = CalculateUrl(rootPath, controllerName, action, httpMethod); return new AttributeRouteModel(new RouteAttribute(url)); } - protected virtual string CalculateUrl(string moduleName, string controllerName, ActionModel action, string httpMethod) + protected virtual string CalculateUrl(string rootPath, string controllerName, ActionModel action, string httpMethod) { - var url = $"api/{moduleName}/{controllerName}"; + var url = $"api/{rootPath}/{controllerName}"; //Add {id} path if needed if (action.Parameters.Any(p => p.ParameterName == "id")) @@ -271,7 +256,7 @@ namespace Volo.Abp.AspNetCore.Mvc } //Add action name if needed - var actionNameInUrl = NormalizeUrlActionName(moduleName, controllerName, action, httpMethod); + var actionNameInUrl = NormalizeUrlActionName(rootPath, controllerName, action, httpMethod); if (!actionNameInUrl.IsNullOrEmpty()) { url += $"/{actionNameInUrl}"; @@ -287,9 +272,9 @@ namespace Volo.Abp.AspNetCore.Mvc return url; } - protected virtual string NormalizeUrlActionName(string moduleName, string controllerName, ActionModel action, string httpMethod) + protected virtual string NormalizeUrlActionName(string rootPath, string controllerName, ActionModel action, string httpMethod) { - var context = new UrlActionNameNormalizerContext(moduleName, controllerName, action, httpMethod, action.ActionName); + var context = new UrlActionNameNormalizerContext(rootPath, controllerName, action, httpMethod, action.ActionName); foreach (var normalizer in _options.AppServiceControllers.UrlActionNameNormalizers) { diff --git a/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpControllerAssemblySetting.cs b/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpControllerAssemblySetting.cs index 447bd59f29..e0fd034214 100644 --- a/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpControllerAssemblySetting.cs +++ b/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpControllerAssemblySetting.cs @@ -8,16 +8,16 @@ namespace Volo.Abp.AspNetCore.Mvc { public Assembly Assembly { get; } - public string ModuleName { get; } + public string RootPath { get; } public Func TypePredicate { get; set; } public Action ControllerModelConfigurer { get; set; } - public AbpControllerAssemblySetting(Assembly assembly, string moduleName) + public AbpControllerAssemblySetting(Assembly assembly, string rootPath) { Assembly = assembly; - ModuleName = moduleName; + RootPath = rootPath; TypePredicate = type => true; ControllerModelConfigurer = controller => { }; diff --git a/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AppServiceControllerOptions.cs b/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AppServiceControllerOptions.cs index d7d4911a2c..e22e1cbd27 100644 --- a/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AppServiceControllerOptions.cs +++ b/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AppServiceControllerOptions.cs @@ -29,9 +29,9 @@ namespace Volo.Abp.AspNetCore.Mvc }; } - public AbpControllerAssemblySettingBuilder CreateFor(Assembly assembly, string moduleName = ModuleApiDescriptionModel.DefaultModuleName) + public AbpControllerAssemblySettingBuilder CreateFor(Assembly assembly, string rootPath = ModuleApiDescriptionModel.DefaultRootPath) { - var setting = new AbpControllerAssemblySetting(assembly, moduleName); + var setting = new AbpControllerAssemblySetting(assembly, rootPath); ControllerAssemblySettings.Add(setting); return new AbpControllerAssemblySettingBuilder(setting); } diff --git a/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs b/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs index f99296a6b3..f9f50dbf67 100644 --- a/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs +++ b/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs @@ -56,7 +56,7 @@ namespace Volo.Abp.AspNetCore.Mvc { var controllerType = apiDescription.ActionDescriptor.AsControllerActionDescriptor().ControllerTypeInfo.AsType(); - var moduleModel = model.GetOrAddModule(GetModuleName(controllerType)); + var moduleModel = model.GetOrAddModule(GetRootPath(controllerType)); var controllerModel = moduleModel.GetOrAddController(GetControllerName(apiDescription), controllerType); @@ -65,7 +65,7 @@ namespace Volo.Abp.AspNetCore.Mvc var uniqueMethodName = GetUniqueActionName(method); if (controllerModel.Actions.ContainsKey(uniqueMethodName)) { - Logger.LogWarning($"Controller '{controllerModel.ControllerName}' contains more than one action with name '{uniqueMethodName}' for module '{moduleModel.Name}'. Ignored: " + method); + Logger.LogWarning($"Controller '{controllerModel.ControllerName}' contains more than one action with name '{uniqueMethodName}' for module '{moduleModel.RootPath}'. Ignored: " + method); return; } @@ -154,18 +154,18 @@ namespace Volo.Abp.AspNetCore.Mvc return modelNameProvider.Name; } - private string GetModuleName(Type controllerType) + private string GetRootPath(Type controllerType) { if (controllerType == null) { - return ModuleApiDescriptionModel.DefaultModuleName; + return ModuleApiDescriptionModel.DefaultRootPath; } foreach (var controllerSetting in _options.AppServiceControllers.ControllerAssemblySettings) { if (Equals(controllerType.Assembly, controllerSetting.Assembly)) { - return controllerSetting.ModuleName; + return controllerSetting.RootPath; } } @@ -175,7 +175,7 @@ namespace Volo.Abp.AspNetCore.Mvc return areaAttr.RouteValue; } - return ModuleApiDescriptionModel.DefaultModuleName; + return ModuleApiDescriptionModel.DefaultRootPath; } } } diff --git a/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/UrlActionNameNormalizerContext.cs b/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/UrlActionNameNormalizerContext.cs index 5cd373c091..37719503bb 100644 --- a/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/UrlActionNameNormalizerContext.cs +++ b/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/UrlActionNameNormalizerContext.cs @@ -4,7 +4,7 @@ namespace Volo.Abp.AspNetCore.Mvc { public class UrlActionNameNormalizerContext { - public string ModuleName { get; } + public string RootPath { get; } public string ControllerName { get; } @@ -14,9 +14,9 @@ namespace Volo.Abp.AspNetCore.Mvc public string ActionNameInUrl { get; set; } - public UrlActionNameNormalizerContext(string moduleName, string controllerName, ActionModel action, string httpMethod, string actionNameInUrl) + public UrlActionNameNormalizerContext(string rootPath, string controllerName, ActionModel action, string httpMethod, string actionNameInUrl) { - ModuleName = moduleName; + RootPath = rootPath; ControllerName = controllerName; Action = action; HttpMethod = httpMethod; diff --git a/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ApplicationApiDescriptionModel.cs b/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ApplicationApiDescriptionModel.cs index 63f9aef716..a7def10625 100644 --- a/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ApplicationApiDescriptionModel.cs +++ b/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ApplicationApiDescriptionModel.cs @@ -26,17 +26,17 @@ namespace Volo.Abp.Http.Modeling public ModuleApiDescriptionModel AddModule(ModuleApiDescriptionModel module) { - if (Modules.ContainsKey(module.Name)) + if (Modules.ContainsKey(module.RootPath)) { - throw new AbpException("There is already a module with same name: " + module.Name); + throw new AbpException("There is already a module with same root path: " + module.RootPath); } - return Modules[module.Name] = module; + return Modules[module.RootPath] = module; } - public ModuleApiDescriptionModel GetOrAddModule(string name) + public ModuleApiDescriptionModel GetOrAddModule(string rootPath) { - return Modules.GetOrAdd(name, () => ModuleApiDescriptionModel.Create(name)); + return Modules.GetOrAdd(rootPath, () => ModuleApiDescriptionModel.Create(rootPath)); } public ApplicationApiDescriptionModel CreateSubModel(string[] modules = null, string[] controllers = null, string[] actions = null) @@ -45,7 +45,7 @@ namespace Volo.Abp.Http.Modeling foreach (var module in Modules.Values) { - if (modules == null || modules.Contains(module.Name)) + if (modules == null || modules.Contains(module.RootPath)) { subModel.AddModule(module.CreateSubModel(controllers, actions)); } diff --git a/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ModuleApiDescriptionModel.cs b/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ModuleApiDescriptionModel.cs index 67366c01ad..5f776d5e4a 100644 --- a/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ModuleApiDescriptionModel.cs +++ b/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ModuleApiDescriptionModel.cs @@ -10,9 +10,9 @@ namespace Volo.Abp.Http.Modeling /// /// "app". /// - public const string DefaultModuleName = "app"; + public const string DefaultRootPath = "app"; - public string Name { get; set; } + public string RootPath { get; set; } public IDictionary Controllers { get; set; } @@ -21,11 +21,11 @@ namespace Volo.Abp.Http.Modeling } - public static ModuleApiDescriptionModel Create(string name) + public static ModuleApiDescriptionModel Create(string rootPath) { return new ModuleApiDescriptionModel { - Name = name, + RootPath = rootPath, Controllers = new Dictionary() }; } @@ -34,7 +34,7 @@ namespace Volo.Abp.Http.Modeling { if (Controllers.ContainsKey(controller.ControllerName)) { - throw new AbpException($"There is already a controller with name: {controller.ControllerName} in module: {Name}"); + throw new AbpException($"There is already a controller with name: {controller.ControllerName} in module: {RootPath}"); } return Controllers[controller.ControllerName] = controller; @@ -47,7 +47,7 @@ namespace Volo.Abp.Http.Modeling public ModuleApiDescriptionModel CreateSubModel(string[] controllers, string[] actions) { - var subModel = Create(Name); + var subModel = Create(RootPath); foreach (var controller in Controllers.Values) { diff --git a/src/Volo.Abp.Http/Volo/Abp/Http/ProxyScripting/Generators/JQuery/JQueryProxyScriptGenerator.cs b/src/Volo.Abp.Http/Volo/Abp/Http/ProxyScripting/Generators/JQuery/JQueryProxyScriptGenerator.cs index f8aead9dda..157d66ca55 100644 --- a/src/Volo.Abp.Http/Volo/Abp/Http/ProxyScripting/Generators/JQuery/JQueryProxyScriptGenerator.cs +++ b/src/Volo.Abp.Http/Volo/Abp/Http/ProxyScripting/Generators/JQuery/JQueryProxyScriptGenerator.cs @@ -34,12 +34,12 @@ namespace Volo.Abp.Http.ProxyScripting.Generators.JQuery private static void AddModuleScript(StringBuilder script, ModuleApiDescriptionModel module) { - //TODO: Eleminate repeating module.Name.Replace("/", ".").ToCamelCase() ! + //TODO: Eleminate repeating module.RootPath.Replace("/", ".").ToCamelCase() ! //TODO: Remove illegal chars (like '-') from module/controller names! - script.AppendLine($"// module '{module.Name.ToCamelCase()}'"); + script.AppendLine($"// module '{module.RootPath.ToCamelCase()}'"); script.AppendLine("(function(){"); - script.AppendLine($"abp.utils.createNamespace(abp, 'services.{module.Name.Replace("/", ".").ToCamelCase()}');"); + script.AppendLine($"abp.utils.createNamespace(abp, 'services.{module.RootPath.Replace("/", ".").ToCamelCase()}');"); foreach (var controller in module.Controllers.Values) { @@ -57,7 +57,7 @@ namespace Volo.Abp.Http.ProxyScripting.Generators.JQuery script.AppendLine(" (function(){"); script.AppendLine(); - script.AppendLine($" abp.services.{module.Name.Replace("/", ".").ToCamelCase()}.{controller.ControllerName.ToCamelCase()} = abp.services.{module.Name.Replace("/", ".").ToCamelCase()}.{controller.ControllerName.ToCamelCase()} || {{}};"); + script.AppendLine($" abp.services.{module.RootPath.Replace("/", ".").ToCamelCase()}.{controller.ControllerName.ToCamelCase()} = abp.services.{module.RootPath.Replace("/", ".").ToCamelCase()}.{controller.ControllerName.ToCamelCase()} || {{}};"); foreach (var action in controller.Actions.Values) { @@ -74,7 +74,7 @@ namespace Volo.Abp.Http.ProxyScripting.Generators.JQuery var parameterList = ProxyScriptingJsFuncHelper.GenerateJsFuncParameterList(action, "ajaxParams"); script.AppendLine($" // action '{action.NameOnClass.ToCamelCase()}'"); - script.AppendLine($" abp.services.{module.Name.Replace("/", ".").ToCamelCase()}.{controller.ControllerName.ToCamelCase()}{ProxyScriptingJsFuncHelper.WrapWithBracketsOrWithDotPrefix(action.NameOnClass.ToCamelCase())} = function({parameterList}) {{"); + script.AppendLine($" abp.services.{module.RootPath.Replace("/", ".").ToCamelCase()}.{controller.ControllerName.ToCamelCase()}{ProxyScriptingJsFuncHelper.WrapWithBracketsOrWithDotPrefix(action.NameOnClass.ToCamelCase())} = function({parameterList}) {{"); script.AppendLine(" return abp.ajax($.extend(true, {"); AddAjaxCallParameters(script, controller, action); diff --git a/src/Volo.Abp.Identity.HttpApi.Client/Volo/Abp/Identity/AbpIdentityHttpApiClientModule.cs b/src/Volo.Abp.Identity.HttpApi.Client/Volo/Abp/Identity/AbpIdentityHttpApiClientModule.cs index 18d8162dcf..113c9d3d77 100644 --- a/src/Volo.Abp.Identity.HttpApi.Client/Volo/Abp/Identity/AbpIdentityHttpApiClientModule.cs +++ b/src/Volo.Abp.Identity.HttpApi.Client/Volo/Abp/Identity/AbpIdentityHttpApiClientModule.cs @@ -7,11 +7,13 @@ namespace Volo.Abp.Identity [DependsOn(typeof(AbpIdentityApplicationContractsModule), typeof(AbpHttpClientModule))] public class AbpIdentityHttpApiClientModule : AbpModule { + public const string RemoteServiceName = "AbpIdentity"; + public override void ConfigureServices(IServiceCollection services) { services.AddAssemblyOf(); - services.AddHttpClientProxies(typeof(AbpIdentityApplicationContractsModule).Assembly, "AbpIdentity"); + services.AddHttpClientProxies(typeof(AbpIdentityApplicationContractsModule).Assembly, RemoteServiceName); } } } \ No newline at end of file