|
|
@ -1,15 +1,43 @@ |
|
|
using System; |
|
|
using LINGYUN.Abp.Cli.ServiceProxying.TypeScript; |
|
|
|
|
|
using System; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using System.Linq; |
|
|
using System.Linq; |
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
|
|
|
using Volo.Abp.Auditing; |
|
|
|
|
|
using Volo.Abp.Data; |
|
|
using Volo.Abp.DependencyInjection; |
|
|
using Volo.Abp.DependencyInjection; |
|
|
|
|
|
using Volo.Abp.Domain.Entities; |
|
|
using Volo.Abp.Http.Modeling; |
|
|
using Volo.Abp.Http.Modeling; |
|
|
|
|
|
using Volo.Abp.MultiTenancy; |
|
|
using Volo.Abp.TextTemplating; |
|
|
using Volo.Abp.TextTemplating; |
|
|
|
|
|
|
|
|
namespace LINGYUN.Abp.Cli.UI.Vben; |
|
|
namespace LINGYUN.Abp.Cli.UI.Vben; |
|
|
|
|
|
|
|
|
public class VbenModelScriptGenerator : IVbenModelScriptGenerator, ISingletonDependency |
|
|
public class VbenModelScriptGenerator : IVbenModelScriptGenerator, ISingletonDependency |
|
|
{ |
|
|
{ |
|
|
|
|
|
internal readonly static string[] DisableInputModelFields = new [] |
|
|
|
|
|
{ |
|
|
|
|
|
nameof(IEntity<string>.Id), |
|
|
|
|
|
nameof(IMultiTenant.TenantId), |
|
|
|
|
|
nameof(IHasConcurrencyStamp.ConcurrencyStamp), |
|
|
|
|
|
nameof(IFullAuditedObject.CreationTime), |
|
|
|
|
|
nameof(IFullAuditedObject.CreatorId), |
|
|
|
|
|
nameof(IFullAuditedObject.LastModificationTime), |
|
|
|
|
|
nameof(IFullAuditedObject.LastModifierId), |
|
|
|
|
|
}; |
|
|
|
|
|
internal readonly static string[] RemoveInputModelFields = new[] |
|
|
|
|
|
{ |
|
|
|
|
|
nameof(IFullAuditedObject.DeletionTime), |
|
|
|
|
|
nameof(IFullAuditedObject.IsDeleted), |
|
|
|
|
|
nameof(IFullAuditedObject.DeleterId), |
|
|
|
|
|
nameof(IHasExtraProperties.ExtraProperties), |
|
|
|
|
|
"SkipCount", |
|
|
|
|
|
"MaxResultCount", |
|
|
|
|
|
"Sorting", |
|
|
|
|
|
"Items", |
|
|
|
|
|
"TotalCount", |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
private readonly ITemplateRenderer _templateRenderer; |
|
|
private readonly ITemplateRenderer _templateRenderer; |
|
|
|
|
|
|
|
|
public VbenModelScriptGenerator( |
|
|
public VbenModelScriptGenerator( |
|
|
@ -32,7 +60,8 @@ public class VbenModelScriptGenerator : IVbenModelScriptGenerator, ISingletonDep |
|
|
.FirstOrDefault(); |
|
|
.FirstOrDefault(); |
|
|
|
|
|
|
|
|
var listResultAction = controllerModel.Actions |
|
|
var listResultAction = controllerModel.Actions |
|
|
.Where(action => action.Value.ReturnValue.TypeSimple.Contains("ListResultDto")) |
|
|
.Where(action => action.Value.ReturnValue.TypeSimple.Contains("ListResultDto") |
|
|
|
|
|
|| action.Value.ReturnValue.TypeSimple.Contains("PagedResultDto")) |
|
|
.Select(action => action.Value) |
|
|
.Select(action => action.Value) |
|
|
.FirstOrDefault(); |
|
|
.FirstOrDefault(); |
|
|
|
|
|
|
|
|
@ -49,69 +78,246 @@ public class VbenModelScriptGenerator : IVbenModelScriptGenerator, ISingletonDep |
|
|
|
|
|
|
|
|
if (listResultAction != null) |
|
|
if (listResultAction != null) |
|
|
{ |
|
|
{ |
|
|
foreach (var inputParamter in listResultAction.Parameters) |
|
|
searchModels.AddRange(GetSearchComponents(appModel, listResultAction.Parameters)); |
|
|
|
|
|
|
|
|
|
|
|
foreach (var searchParamter in listResultAction.Parameters) |
|
|
{ |
|
|
{ |
|
|
if (appModel.Types.TryGetValue(inputParamter.Type, out var inputModelType)) |
|
|
var abpBaseType = GetAbpBaseType(appModel, searchParamter.TypeSimple); |
|
|
|
|
|
if (abpBaseType != null) |
|
|
{ |
|
|
{ |
|
|
var span = inputModelType.Properties.Length > 3 ? 8 |
|
|
searchModels.AddRange(GetSearchComponents(appModel, abpBaseType)); |
|
|
: inputModelType.Properties.Length > 2 ? 12 |
|
|
} |
|
|
: 24; |
|
|
|
|
|
foreach (var inputModelProp in inputModelType.Properties) |
|
|
|
|
|
{ |
|
|
|
|
|
var component = new ComponentModel |
|
|
|
|
|
{ |
|
|
|
|
|
Name = inputModelProp.JsonName ?? inputModelProp.Name.ToCamelCase(), |
|
|
|
|
|
Component = "Input", |
|
|
|
|
|
DisplayName = "DisplayName:" + inputModelProp.Name.ToPascalCase(), |
|
|
|
|
|
Required = inputModelProp.IsRequired, |
|
|
|
|
|
ColProps = "" + |
|
|
|
|
|
"{" + |
|
|
|
|
|
$"span: {span}" + |
|
|
|
|
|
"}", |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
if (appModel.Types.TryGetValue(inputModelProp.Type, out var inputModelPropType) && |
|
|
|
|
|
inputModelPropType.IsEnum) |
|
|
|
|
|
{ |
|
|
|
|
|
component.Component = "Select"; |
|
|
|
|
|
|
|
|
|
|
|
var optionsStr = Environment.NewLine; |
|
|
|
|
|
|
|
|
|
|
|
var options = new object[inputModelPropType.EnumNames.Length]; |
|
|
|
|
|
for (var index = 0; index < inputModelPropType.EnumNames.Length; index++) |
|
|
|
|
|
{ |
|
|
|
|
|
optionsStr += "" + |
|
|
|
|
|
"{" + |
|
|
|
|
|
$"label: {inputModelPropType.EnumNames[index]}," + |
|
|
|
|
|
$"value: {inputModelPropType.EnumValues[index]}," + |
|
|
|
|
|
"}" + |
|
|
|
|
|
"" + Environment.NewLine; |
|
|
|
|
|
} |
|
|
|
|
|
component.ComponentProps = "" + |
|
|
|
|
|
"{" + |
|
|
|
|
|
$"options: [{optionsStr}]" + |
|
|
|
|
|
"}"; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
searchModels.Add(component); |
|
|
var inputParamterType = ReplaceAbpBaseType(searchParamter.TypeSimple); |
|
|
} |
|
|
if (appModel.Types.TryGetValue(inputParamterType, out var inputModelType)) |
|
|
|
|
|
{ |
|
|
|
|
|
searchModels.AddRange(GetSearchComponents(appModel, inputModelType)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
searchModels = searchModels.DistinctBy(model => model.Name).ToList(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var createOrUpdateAction = controllerModel.Actions |
|
|
var createAndUpdateActions = controllerModel.Actions |
|
|
.Where(action => action.Value.UniqueName.Contains("Create") || action.Value.UniqueName.Contains("Update")) |
|
|
.Where(action => action.Value.UniqueName.Contains("CreateAsync") || action.Value.UniqueName.Contains("UpdateAsync")) |
|
|
.Select(action => action.Value) |
|
|
.Select(action => action.Value) |
|
|
.FirstOrDefault(); |
|
|
.ToList(); |
|
|
|
|
|
|
|
|
|
|
|
foreach (var createAndUpdateAction in createAndUpdateActions) |
|
|
|
|
|
{ |
|
|
|
|
|
foreach (var createAndUpdateParamter in createAndUpdateAction.Parameters) |
|
|
|
|
|
{ |
|
|
|
|
|
var abpBaseType = GetAbpBaseType(appModel, createAndUpdateParamter.TypeSimple); |
|
|
|
|
|
if (abpBaseType != null) |
|
|
|
|
|
{ |
|
|
|
|
|
inputModels.AddRange(GetComponents(appModel, abpBaseType)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var inputParamterType = ReplaceAbpBaseType(createAndUpdateParamter.TypeSimple); |
|
|
|
|
|
if (appModel.Types.TryGetValue(inputParamterType, out var inputModelType)) |
|
|
|
|
|
{ |
|
|
|
|
|
inputModels.AddRange(GetComponents(appModel, inputModelType)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
inputModels = inputModels.DistinctBy(model => model.Name).ToList(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var modelDataContent = await _templateRenderer.RenderAsync( |
|
|
|
|
|
"VbenModelData", |
|
|
|
|
|
new |
|
|
|
|
|
{ |
|
|
|
|
|
Key = "id", |
|
|
|
|
|
RemoteService = moduleDefinition.RemoteServiceName, |
|
|
|
|
|
ExistsSearchModels = searchModels.Any(), |
|
|
|
|
|
SearchModels = searchModels, |
|
|
|
|
|
InputModels = inputModels, |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
return modelDataContent; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected virtual List<ComponentModel> GetSearchComponents(ApplicationApiDescriptionModel appModel, TypeApiDescriptionModel parameter) |
|
|
|
|
|
{ |
|
|
|
|
|
var components = new List<ComponentModel>(); |
|
|
|
|
|
|
|
|
|
|
|
if (!parameter.BaseType.IsNullOrWhiteSpace()) |
|
|
|
|
|
{ |
|
|
|
|
|
var abpBaseType = GetAbpBaseType(appModel, parameter.BaseType); |
|
|
|
|
|
if (abpBaseType != null) |
|
|
|
|
|
{ |
|
|
|
|
|
components.AddRange(GetSearchComponents(appModel, abpBaseType)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var baseParamterType = ReplaceAbpBaseType(parameter.BaseType); |
|
|
|
|
|
if (appModel.Types.TryGetValue(baseParamterType, out var baseModelType)) |
|
|
|
|
|
{ |
|
|
|
|
|
components.AddRange(GetSearchComponents(appModel, baseModelType)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
components.AddRange(GetSearchComponents(appModel, parameter.Properties)); |
|
|
|
|
|
|
|
|
|
|
|
return components; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected virtual List<ComponentModel> GetSearchComponents(ApplicationApiDescriptionModel appModel, IEnumerable<PropertyApiDescriptionModel> parameters) |
|
|
|
|
|
{ |
|
|
|
|
|
var components = new List<ComponentModel>(); |
|
|
|
|
|
|
|
|
|
|
|
var span = parameters.Count() > 3 ? 8 |
|
|
|
|
|
: parameters.Count() > 2 ? 12 |
|
|
|
|
|
: 24; |
|
|
|
|
|
|
|
|
|
|
|
foreach (var inputModelProp in parameters) |
|
|
|
|
|
{ |
|
|
|
|
|
if (RemoveInputModelFields.Contains(inputModelProp.Name, StringComparer.InvariantCultureIgnoreCase)) |
|
|
|
|
|
{ |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
var component = new ComponentModel |
|
|
|
|
|
{ |
|
|
|
|
|
Name = inputModelProp.JsonName ?? inputModelProp.Name.ToCamelCase(), |
|
|
|
|
|
Component = "Input", |
|
|
|
|
|
DisplayName = "DisplayName:" + inputModelProp.Name.ToPascalCase(), |
|
|
|
|
|
Required = inputModelProp.IsRequired, |
|
|
|
|
|
ColProps = "" + |
|
|
|
|
|
"{" + |
|
|
|
|
|
$"span: {span}" + |
|
|
|
|
|
"}", |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
if (appModel.Types.TryGetValue(inputModelProp.Type, out var inputModelPropType) && |
|
|
|
|
|
inputModelPropType.IsEnum) |
|
|
|
|
|
{ |
|
|
|
|
|
component.Component = "Select"; |
|
|
|
|
|
|
|
|
|
|
|
var optionsStr = Environment.NewLine; |
|
|
|
|
|
|
|
|
|
|
|
var options = new object[inputModelPropType.EnumNames.Length]; |
|
|
|
|
|
for (var index = 0; index < inputModelPropType.EnumNames.Length; index++) |
|
|
|
|
|
{ |
|
|
|
|
|
optionsStr += "" + |
|
|
|
|
|
"{" + |
|
|
|
|
|
$"label: {inputModelPropType.EnumNames[index]}," + |
|
|
|
|
|
$"value: {inputModelPropType.EnumValues[index]}," + |
|
|
|
|
|
"}" + |
|
|
|
|
|
"" + Environment.NewLine; |
|
|
|
|
|
} |
|
|
|
|
|
component.ComponentProps = "" + |
|
|
|
|
|
"{" + |
|
|
|
|
|
$"options: [{optionsStr}]" + |
|
|
|
|
|
"}"; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
components.Add(component); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return components; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected virtual List<ComponentModel> GetSearchComponents(ApplicationApiDescriptionModel appModel, IEnumerable<ParameterApiDescriptionModel> parameters) |
|
|
|
|
|
{ |
|
|
|
|
|
var components = new List<ComponentModel>(); |
|
|
|
|
|
|
|
|
|
|
|
var span = parameters.Count() > 3 ? 8 |
|
|
|
|
|
: parameters.Count() > 2 ? 12 |
|
|
|
|
|
: 24; |
|
|
|
|
|
|
|
|
|
|
|
foreach (var inputModelProp in parameters) |
|
|
|
|
|
{ |
|
|
|
|
|
if (RemoveInputModelFields.Contains(inputModelProp.Name, StringComparer.InvariantCultureIgnoreCase)) |
|
|
|
|
|
{ |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
var component = new ComponentModel |
|
|
|
|
|
{ |
|
|
|
|
|
Name = inputModelProp.JsonName ?? inputModelProp.Name.ToCamelCase(), |
|
|
|
|
|
Component = "Input", |
|
|
|
|
|
DisplayName = "DisplayName:" + inputModelProp.Name.ToPascalCase(), |
|
|
|
|
|
Required = !inputModelProp.IsOptional, |
|
|
|
|
|
ColProps = "" + |
|
|
|
|
|
"{" + |
|
|
|
|
|
$"span: {span}" + |
|
|
|
|
|
"}", |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
if (appModel.Types.TryGetValue(inputModelProp.Type, out var inputModelPropType) && |
|
|
|
|
|
inputModelPropType.IsEnum) |
|
|
|
|
|
{ |
|
|
|
|
|
component.Component = "Select"; |
|
|
|
|
|
|
|
|
if (createOrUpdateAction != null) |
|
|
var optionsStr = Environment.NewLine; |
|
|
|
|
|
|
|
|
|
|
|
var options = new object[inputModelPropType.EnumNames.Length]; |
|
|
|
|
|
for (var index = 0; index < inputModelPropType.EnumNames.Length; index++) |
|
|
|
|
|
{ |
|
|
|
|
|
optionsStr += "" + |
|
|
|
|
|
"{" + |
|
|
|
|
|
$"label: {inputModelPropType.EnumNames[index]}," + |
|
|
|
|
|
$"value: {inputModelPropType.EnumValues[index]}," + |
|
|
|
|
|
"}" + |
|
|
|
|
|
"" + Environment.NewLine; |
|
|
|
|
|
} |
|
|
|
|
|
component.ComponentProps = "" + |
|
|
|
|
|
"{" + |
|
|
|
|
|
$"options: [{optionsStr}]" + |
|
|
|
|
|
"}"; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
components.Add(component); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return components; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected virtual List<ComponentModel> GetComponents(ApplicationApiDescriptionModel appModel, TypeApiDescriptionModel parameter) |
|
|
|
|
|
{ |
|
|
|
|
|
var components = new List<ComponentModel>(); |
|
|
|
|
|
|
|
|
|
|
|
if (!parameter.BaseType.IsNullOrWhiteSpace()) |
|
|
{ |
|
|
{ |
|
|
foreach (var createOrUpdateParamter in createOrUpdateAction.Parameters) |
|
|
var abpBaseType = GetAbpBaseType(appModel, parameter.BaseType); |
|
|
|
|
|
if (abpBaseType != null) |
|
|
{ |
|
|
{ |
|
|
if (appModel.Types.TryGetValue(createOrUpdateParamter.Type, out var inputModelType)) |
|
|
components.AddRange(GetComponents(appModel, abpBaseType)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var baseParamterType = ReplaceAbpBaseType(parameter.BaseType); |
|
|
|
|
|
if (appModel.Types.TryGetValue(baseParamterType, out var baseModelType)) |
|
|
|
|
|
{ |
|
|
|
|
|
components.AddRange(GetComponents(appModel, baseModelType)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
foreach (var modelProp in parameter.Properties) |
|
|
|
|
|
{ |
|
|
|
|
|
var inputParamterType = ReplaceAbpBaseType(modelProp.TypeSimple); |
|
|
|
|
|
if (appModel.Types.TryGetValue(inputParamterType, out var inputModelType)) |
|
|
|
|
|
{ |
|
|
|
|
|
if (!inputModelType.BaseType.IsNullOrWhiteSpace()) |
|
|
|
|
|
{ |
|
|
|
|
|
var abpBaseType = GetAbpBaseType(appModel, inputModelType.BaseType); |
|
|
|
|
|
if (abpBaseType != null) |
|
|
|
|
|
{ |
|
|
|
|
|
components.AddRange(GetComponents(appModel, abpBaseType)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var baseParamterType = ReplaceAbpBaseType(inputModelType.BaseType); |
|
|
|
|
|
if (appModel.Types.TryGetValue(baseParamterType, out var baseModelType)) |
|
|
|
|
|
{ |
|
|
|
|
|
components.AddRange(GetComponents(appModel, baseModelType)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (inputModelType.Properties != null) |
|
|
{ |
|
|
{ |
|
|
foreach (var inputModelProp in inputModelType.Properties) |
|
|
foreach (var inputModelProp in inputModelType.Properties) |
|
|
{ |
|
|
{ |
|
|
|
|
|
if (RemoveInputModelFields.Contains(inputModelProp.Name, StringComparer.InvariantCultureIgnoreCase)) |
|
|
|
|
|
{ |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
var component = new ComponentModel |
|
|
var component = new ComponentModel |
|
|
{ |
|
|
{ |
|
|
Name = inputModelProp.JsonName ?? inputModelProp.Name.ToCamelCase(), |
|
|
Name = inputModelProp.JsonName ?? inputModelProp.Name.ToCamelCase(), |
|
|
@ -125,23 +331,48 @@ public class VbenModelScriptGenerator : IVbenModelScriptGenerator, ISingletonDep |
|
|
ComponentProps = "{}" |
|
|
ComponentProps = "{}" |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
inputModels.Add(component); |
|
|
if (DisableInputModelFields.Contains(inputModelProp.Name, StringComparer.InvariantCultureIgnoreCase)) |
|
|
|
|
|
{ |
|
|
|
|
|
component.Show = false; |
|
|
|
|
|
component.Disabled = true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
components.Add(component); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
else |
|
|
|
|
|
|
|
|
var modelDataContent = await _templateRenderer.RenderAsync( |
|
|
|
|
|
"VbenModelData", |
|
|
|
|
|
new |
|
|
|
|
|
{ |
|
|
{ |
|
|
RemoteService = moduleDefinition.RemoteServiceName, |
|
|
if (RemoveInputModelFields.Contains(modelProp.Name, StringComparer.InvariantCultureIgnoreCase)) |
|
|
ExistsSearchModels = searchModels.Any(), |
|
|
{ |
|
|
SearchModels = searchModels, |
|
|
return components; |
|
|
InputModels = inputModels, |
|
|
} |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
return modelDataContent; |
|
|
var component = new ComponentModel |
|
|
|
|
|
{ |
|
|
|
|
|
Name = modelProp.JsonName ?? modelProp.Name.ToCamelCase(), |
|
|
|
|
|
Component = "Input", |
|
|
|
|
|
DisplayName = "DisplayName:" + modelProp.Name.ToPascalCase(), |
|
|
|
|
|
Required = modelProp.IsRequired, |
|
|
|
|
|
ColProps = "" + |
|
|
|
|
|
"{" + |
|
|
|
|
|
"span: 24" + |
|
|
|
|
|
"}", |
|
|
|
|
|
ComponentProps = "{}" |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
if (DisableInputModelFields.Contains(modelProp.Name, StringComparer.InvariantCultureIgnoreCase)) |
|
|
|
|
|
{ |
|
|
|
|
|
component.Show = false; |
|
|
|
|
|
component.Disabled = true; |
|
|
|
|
|
component.Width = 1; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
components.Add(component); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return components; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public async virtual Task<string> CreateTable( |
|
|
public async virtual Task<string> CreateTable( |
|
|
@ -164,37 +395,71 @@ public class VbenModelScriptGenerator : IVbenModelScriptGenerator, ISingletonDep |
|
|
|
|
|
|
|
|
if (listResultAction != null) |
|
|
if (listResultAction != null) |
|
|
{ |
|
|
{ |
|
|
foreach (var inputParamter in listResultAction.Parameters) |
|
|
var abpBaseType = GetAbpBaseType(appModel, listResultAction.ReturnValue.TypeSimple); |
|
|
|
|
|
if (abpBaseType != null) |
|
|
{ |
|
|
{ |
|
|
if (appModel.Types.TryGetValue(inputParamter.Type, out var inputModelType)) |
|
|
ouputModels.AddRange(GetComponents(appModel, abpBaseType)); |
|
|
{ |
|
|
} |
|
|
var span = inputModelType.Properties.Length > 3 ? 8 |
|
|
|
|
|
: inputModelType.Properties.Length > 2 ? 12 |
|
|
|
|
|
: 24; |
|
|
|
|
|
foreach (var inputModelProp in inputModelType.Properties) |
|
|
|
|
|
{ |
|
|
|
|
|
var component = new ComponentModel |
|
|
|
|
|
{ |
|
|
|
|
|
Name = inputModelProp.JsonName ?? inputModelProp.Name.ToCamelCase(), |
|
|
|
|
|
DisplayName = "DisplayName:" + inputModelProp.Name.ToPascalCase() |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
ouputModels.Add(component); |
|
|
var returnValueType = ReplaceAbpBaseType(listResultAction.ReturnValue.TypeSimple); |
|
|
} |
|
|
if (appModel.Types.TryGetValue(returnValueType, out var inputModelType)) |
|
|
} |
|
|
{ |
|
|
|
|
|
ouputModels.AddRange(GetComponents(appModel, inputModelType)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ouputModels = ouputModels.DistinctBy(model => model.Name).ToList(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var tableDataContent = await _templateRenderer.RenderAsync( |
|
|
var tableDataContent = await _templateRenderer.RenderAsync( |
|
|
"VbenTableData", |
|
|
"VbenTableData", |
|
|
new |
|
|
new |
|
|
{ |
|
|
{ |
|
|
|
|
|
Key = "id", |
|
|
RemoteService = moduleDefinition.RemoteServiceName, |
|
|
RemoteService = moduleDefinition.RemoteServiceName, |
|
|
OuputModels = ouputModels, |
|
|
OuputModels = ouputModels, |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
return tableDataContent; |
|
|
return tableDataContent; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected virtual bool IsAbpBaseType(string typeSimple) => TypeScriptModelGenerator.AbpBaseTypes.Any(typeSimple.StartsWith); |
|
|
|
|
|
|
|
|
|
|
|
protected virtual string GetAbpBaseType(string typeSimple) => |
|
|
|
|
|
TypeScriptModelGenerator.AbpBaseTypes.FirstOrDefault(typeSimple.StartsWith); |
|
|
|
|
|
|
|
|
|
|
|
protected virtual TypeApiDescriptionModel GetAbpBaseType(ApplicationApiDescriptionModel appModel, string typeSimple) |
|
|
|
|
|
{ |
|
|
|
|
|
if (IsAbpBaseType(typeSimple)) |
|
|
|
|
|
{ |
|
|
|
|
|
var abpBaseType = GetAbpBaseType(typeSimple); |
|
|
|
|
|
|
|
|
|
|
|
if (abpBaseType == typeSimple) |
|
|
|
|
|
{ |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return appModel.Types |
|
|
|
|
|
.Where(type => type.Key.StartsWith(abpBaseType)) |
|
|
|
|
|
.Select(type => type.Value) |
|
|
|
|
|
.FirstOrDefault(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected virtual string ReplaceAbpBaseType(string typeSimple) |
|
|
|
|
|
{ |
|
|
|
|
|
var abpBaseType = TypeScriptModelGenerator.AbpBaseTypes.FirstOrDefault(basType => typeSimple.StartsWith(basType)); |
|
|
|
|
|
if (!abpBaseType.IsNullOrWhiteSpace()) |
|
|
|
|
|
{ |
|
|
|
|
|
typeSimple = typeSimple |
|
|
|
|
|
.Replace(abpBaseType, "") |
|
|
|
|
|
.Replace("<", "") |
|
|
|
|
|
.Replace(">", ""); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return typeSimple; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public class ComponentModel |
|
|
public class ComponentModel |
|
|
@ -206,6 +471,8 @@ public class ComponentModel |
|
|
public object ComponentProps { get; set; } |
|
|
public object ComponentProps { get; set; } |
|
|
public string Align { get; set; } = "left"; |
|
|
public string Align { get; set; } = "left"; |
|
|
public int Width { get; set; } = 120; |
|
|
public int Width { get; set; } = 120; |
|
|
|
|
|
public bool Show { get; set; } = true; |
|
|
|
|
|
public bool Disabled { get; set; } = false; |
|
|
public bool Sorter { get; set; } = true; |
|
|
public bool Sorter { get; set; } = true; |
|
|
public bool Resizable { get; set; } = true; |
|
|
public bool Resizable { get; set; } = true; |
|
|
public bool Required { get; set; } = false; |
|
|
public bool Required { get; set; } = false; |
|
|
|