Browse Source

generate proxy bug fixes

pull/3192/head
Arkat Erol 7 years ago
parent
commit
91a169bd3f
  1. 25
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GenerateProxyCommand.cs

25
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GenerateProxyCommand.cs

@ -103,7 +103,7 @@ namespace Volo.Abp.Cli.Commands
serviceFileText.AppendLine("import { Observable } from 'rxjs';"); serviceFileText.AppendLine("import { Observable } from 'rxjs';");
serviceFileText.AppendLine("[secondTypeList]"); serviceFileText.AppendLine("[secondTypeList]");
serviceFileText.AppendLine(""); serviceFileText.AppendLine("");
serviceFileText.AppendLine("@Injectable()"); serviceFileText.AppendLine("@Injectable({providedIn: 'root'})");
serviceFileText.AppendLine("export class [controllerName]Service {"); serviceFileText.AppendLine("export class [controllerName]Service {");
serviceFileText.AppendLine(" constructor(private restService: RestService) {}"); serviceFileText.AppendLine(" constructor(private restService: RestService) {}");
serviceFileText.AppendLine(""); serviceFileText.AppendLine("");
@ -193,7 +193,13 @@ namespace Volo.Abp.Cli.Commands
{ {
parametersText.Append($"params = {{}} as {type}"); parametersText.Append($"params = {{}} as {type}");
modelBindingExtra = ", params"; modelBindingExtra = ", params";
secondTypeList.Add(type); if (!string.IsNullOrWhiteSpace(modelIndex))
{
secondTypeList.Add(type);
}
else {
firstTypeList.Add(type);
}
break; break;
} }
} }
@ -254,6 +260,7 @@ namespace Volo.Abp.Cli.Commands
"Void" => "void", "Void" => "void",
"String" => "string", "String" => "string",
"IActionResult" => "void", "IActionResult" => "void",
"ActionResult" => "void",
_ => type _ => type
}; };
@ -279,7 +286,7 @@ namespace Volo.Abp.Cli.Commands
modelBindingExtra = ", params: { " + string.Join(", ", modelBindingExtraList.ToArray()) + " }"; modelBindingExtra = ", params: { " + string.Join(", ", modelBindingExtraList.ToArray()) + " }";
} }
var url = ((string)action["url"]).Replace("/{", "/${"); var url = (((string)action["url"]).Replace("/{", "/${")).ToLower();
var httpMethod = (string)action["httpMethod"]; var httpMethod = (string)action["httpMethod"];
serviceFileText.AppendLine( serviceFileText.AppendLine(
@ -384,6 +391,7 @@ namespace Volo.Abp.Cli.Commands
|| returnValueType == "System.String" || returnValueType == "System.String"
|| returnValueType == "System.Void" || returnValueType == "System.Void"
|| returnValueType.Contains("IActionResult") || returnValueType.Contains("IActionResult")
|| returnValueType.Contains("ActionResult")
|| returnValueType.Contains("IStringValueType") || returnValueType.Contains("IStringValueType")
|| returnValueType.Contains("IValueValidator") || returnValueType.Contains("IValueValidator")
) )
@ -459,10 +467,6 @@ namespace Volo.Abp.Cli.Commands
foreach (var property in type["properties"]) foreach (var property in type["properties"])
{ {
var propertyName = (string)property["name"]; var propertyName = (string)property["name"];
if (propertyName == "RoleNames")
{
}
propertyName = (char.ToLower(propertyName[0]) + propertyName.Substring(1)); propertyName = (char.ToLower(propertyName[0]) + propertyName.Substring(1));
var typeSimple = (string)property["typeSimple"]; var typeSimple = (string)property["typeSimple"];
@ -498,7 +502,12 @@ namespace Volo.Abp.Cli.Commands
&& typeSimple != "number[]" && typeSimple != "number[]"
) )
{ {
typeSimple = "any" + (typeSimple.Contains("[]") ? "[]" : ""); var typeSimpleModelName = typeSimple.PascalToKebabCase() + ".ts";
var modelPath = $"src/app/{rootPath}/shared/models/{typeSimpleModelName}";
if (!File.Exists(modelPath))
{
typeSimple = "any" + (typeSimple.Contains("[]") ? "[]" : "");
}
} }
if (propertyList.Any(p => p.Key == baseTypeName && p.Value.Any(q => q.Key == propertyName && q.Value == typeSimple))) if (propertyList.Any(p => p.Key == baseTypeName && p.Value.Any(q => q.Key == propertyName && q.Value == typeSimple)))

Loading…
Cancel
Save