feat:support array root
This commit is contained in:
parent
aa2212f05e
commit
fefc6d1d63
@ -4,6 +4,7 @@ using Newtonsoft.Json;
|
||||
using InterfaceForward.Application.Contracts.Dtos.Interface;
|
||||
using InterfaceForward.Application.Helpers;
|
||||
using InterfaceForward.Application.Services.Parameter;
|
||||
using InterfaceForward.Domain.Shared;
|
||||
using InterfaceForward.Domain.Shared.Enum;
|
||||
using InterfaceForward.Repositories;
|
||||
using InterfaceForward.Repositories.Interface.Entitys;
|
||||
@ -130,6 +131,17 @@ public class ServiceProviderInterfaceService : ApplicationService
|
||||
[HttpPost("Interface/SaveServiceProviderInterface")]
|
||||
public async Task<int> SaveServiceProviderInterfaceAsync(ServiceProviderInterfaceInput input)
|
||||
{
|
||||
input.InParameterList.ForEach(x =>
|
||||
{
|
||||
if (x.PId == 0 && x.Type == ParameterType.Array && x.Name == GlobalConst.RootParameterName)
|
||||
x.Name = string.Empty;
|
||||
});
|
||||
input.OutParameterList.ForEach(x =>
|
||||
{
|
||||
if (x.PId == 0 && x.Type == ParameterType.Array && x.Name == GlobalConst.RootParameterName)
|
||||
x.Name = string.Empty;
|
||||
});
|
||||
|
||||
switch (input.OptionType)
|
||||
{
|
||||
case OptionType.新增:
|
||||
|
||||
@ -4,6 +4,7 @@ using Newtonsoft.Json;
|
||||
using InterfaceForward.Application.Contracts.Dtos.Interface;
|
||||
using InterfaceForward.Application.Helpers;
|
||||
using InterfaceForward.Application.Services.Parameter;
|
||||
using InterfaceForward.Domain.Shared;
|
||||
using InterfaceForward.Domain.Shared.Enum;
|
||||
using InterfaceForward.Repositories;
|
||||
using InterfaceForward.Repositories.Interface.Entitys;
|
||||
@ -139,6 +140,17 @@ public class SystemInterfaceService : ApplicationService
|
||||
[HttpPost("Interface/SaveSystemInterface")]
|
||||
public async Task SaveSystemInterfaceAsync(SystemInterfaceInput input)
|
||||
{
|
||||
input.InParameterList.ForEach(x =>
|
||||
{
|
||||
if (x.PId == 0 && x.Type == ParameterType.Array && x.Name == GlobalConst.RootParameterName)
|
||||
x.Name = string.Empty;
|
||||
});
|
||||
input.OutParameterList.ForEach(x =>
|
||||
{
|
||||
if (x.PId == 0 && x.Type == ParameterType.Array && x.Name == GlobalConst.RootParameterName)
|
||||
x.Name = string.Empty;
|
||||
});
|
||||
|
||||
switch (input.OptionType)
|
||||
{
|
||||
case OptionType.新增:
|
||||
|
||||
@ -5,6 +5,7 @@ using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using InterfaceForward.Application.Contracts.Dtos.Interface;
|
||||
using InterfaceForward.Application.Helpers;
|
||||
using InterfaceForward.Domain.Shared;
|
||||
using InterfaceForward.Domain.Shared.Enum;
|
||||
using InterfaceForward.Repositories.Interface.Entitys;
|
||||
using InterfaceForward.Repositories.Interface.Services;
|
||||
@ -195,7 +196,8 @@ public class ParameterService : ApplicationService
|
||||
{
|
||||
idx++;
|
||||
var res = JArray2List(arr, ref idx, 1);
|
||||
res.Insert(0, new(1, 0, "arr", ParameterType.Array, annotation));
|
||||
var name = pid == 0 ? GlobalConst.RootParameterName : "arr";
|
||||
res.Insert(0, new(1, 0, name, ParameterType.Array, annotation));
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@ -25,6 +25,11 @@ public static class GlobalConst
|
||||
/// </summary>
|
||||
public const string AppId = nameof(AppId);
|
||||
|
||||
/// <summary>
|
||||
/// 参数根类型为数组时,参数的命名
|
||||
/// </summary>
|
||||
public const string RootParameterName = "array";
|
||||
|
||||
/// <summary>
|
||||
/// 服务商接口qps redis key前缀
|
||||
/// </summary>
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using InterfaceForward.Domain.Shared.Enum;
|
||||
using InterfaceForward.Application.Contracts.Dtos.Interface;
|
||||
using InterfaceForward.Domain.Shared;
|
||||
using InterfaceForward.Repositories.Interface.Entitys;
|
||||
using InterfaceForward.Repositories.Interface.ValueObjects;
|
||||
using InterfaceForward.Repositories.Parameter.VO;
|
||||
@ -70,7 +71,15 @@ public class InterfaceRepository : BasicRepository<InterfaceEntity>, IInterfaceR
|
||||
.WhereIF(onlyLeafs, x => x.Type != ParameterType.Object && x.Type != ParameterType.Array)
|
||||
.OrderBy(x => x.Sort);
|
||||
|
||||
return await query.Select<InterfaceParameterOutputValueObject>().ToListAsync();
|
||||
var res = await query.Select<InterfaceParameterOutputValueObject>().ToListAsync();
|
||||
|
||||
res.ForEach(x =>
|
||||
{
|
||||
if (x.PId == 0 && x.Type == (int)ParameterType.Array && x.Name == string.Empty)
|
||||
x.Name = GlobalConst.RootParameterName;
|
||||
});
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
Loading…
Reference in New Issue
Block a user