From 2c63877a889836895c4caf89575a34b0d9fa1f1d Mon Sep 17 00:00:00 2001 From: Arkat Erol Date: Fri, 20 Mar 2020 16:50:38 +0300 Subject: [PATCH] apiName added for generate proxy --- .../Volo/Abp/Cli/Commands/GenerateProxyCommand.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GenerateProxyCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GenerateProxyCommand.cs index 17fe2d3781..12fc5af525 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GenerateProxyCommand.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GenerateProxyCommand.cs @@ -67,7 +67,8 @@ namespace Volo.Abp.Cli.Commands var data = JObject.Parse(json); Logger.LogInformation("Modules are combining"); - var moduleList = GetCombinedModules(data, module); + var apiNameList = new Dictionary(); + var moduleList = GetCombinedModules(data, module, out apiNameList); if (moduleList.Count < 1) { @@ -85,6 +86,7 @@ namespace Volo.Abp.Cli.Commands var moduleValue = JObject.Parse(moduleItem.Value); var rootPath = moduleItem.Key; + var apiName = apiNameList.Where(p => p.Key == rootPath).Select(p => p.Value).FirstOrDefault(); Logger.LogInformation($"{rootPath} directory is creating"); @@ -105,6 +107,8 @@ namespace Volo.Abp.Cli.Commands serviceFileText.AppendLine(""); serviceFileText.AppendLine("@Injectable({providedIn: 'root'})"); serviceFileText.AppendLine("export class [controllerName]Service {"); + serviceFileText.AppendLine(" apiName = '"+ apiName + "';"); + serviceFileText.AppendLine(""); serviceFileText.AppendLine(" constructor(private restService: RestService) {}"); serviceFileText.AppendLine(""); @@ -309,8 +313,8 @@ namespace Volo.Abp.Cli.Commands serviceFileText.AppendLine( url.Contains("${") - ? $" return this.restService.request({{ url: `/{url}`, method: '{httpMethod}'{bodyExtra}{modelBindingExtra} }});" - : $" return this.restService.request({{ url: '/{url}', method: '{httpMethod}'{bodyExtra}{modelBindingExtra} }});"); + ? $" return this.restService.request({{ url: `/{url}`, method: '{httpMethod}'{bodyExtra}{modelBindingExtra} }},{{ apiName: this.apiName }});" + : $" return this.restService.request({{ url: '/{url}', method: '{httpMethod}'{bodyExtra}{modelBindingExtra} }},{{ apiName: this.apiName }});"); serviceFileText.AppendLine(" }"); @@ -369,13 +373,15 @@ namespace Volo.Abp.Cli.Commands Logger.LogInformation("Completed!"); } - private Dictionary GetCombinedModules(JToken data, string module) + private Dictionary GetCombinedModules(JToken data, string module, out Dictionary apiNameList) { var moduleList = new Dictionary(); + apiNameList = new Dictionary(); foreach (var moduleItem in data["modules"]) { var rootPath = ((string)moduleItem.First["rootPath"]).ToLower(); + var apiName = (string)moduleItem.First["remoteServiceName"]; if (moduleList.Any(p => p.Key == rootPath)) { @@ -385,6 +391,7 @@ namespace Volo.Abp.Cli.Commands } else { + apiNameList.Add(rootPath, apiName); moduleList.Add(rootPath, moduleItem.First["controllers"].ToString()); } }