fix:none
This commit is contained in:
parent
df9afe876b
commit
0202800d7a
@ -584,7 +584,9 @@ public class DefaultForwardFlow : IForwardFlow, ITransientDependency
|
|||||||
GlobalConst.DateTime => TurnDate(now, description),
|
GlobalConst.DateTime => TurnDate(now, description),
|
||||||
GlobalConst.Url => context.TargetInterface.RequestAddress,
|
GlobalConst.Url => context.TargetInterface.RequestAddress,
|
||||||
GlobalConst.FromAccount => context.GetAccountFieldValueOrNull(name) ?? string.Empty,
|
GlobalConst.FromAccount => context.GetAccountFieldValueOrNull(name) ?? string.Empty,
|
||||||
GlobalConst.FromMappingBody => GlobalConst.FromMappingBody,
|
GlobalConst.FromMappingBody => context.TargetInterface.ContentType == ContentType.FormUrlEncoded
|
||||||
|
? GlobalConst.FromMappingBody
|
||||||
|
: JsonConvert.SerializeObject(context.OriginalInterfaceMappedInput),
|
||||||
_ => value
|
_ => value
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -367,8 +367,8 @@ public class InterfaceService : ApplicationService
|
|||||||
switch (input.ContentType)
|
switch (input.ContentType)
|
||||||
{
|
{
|
||||||
case ContentType.None:
|
case ContentType.None:
|
||||||
if (input.InParameterList.Count > 0 || input.RequestBodyParameterList.Count > 0 || input.MappingBodyParameterList.Count > 0 || input.BodyFormParameterList.Count > 0)
|
if (input.InParameterList.Count > 0 || input.RequestBodyParameterList.Count > 0 || input.BodyFormParameterList.Count > 0)
|
||||||
throw new BusinessException(message: "None 下游接口只能维护 Query/Header/Response");
|
throw new BusinessException(message: "None 下游接口只能维护 Query/Header/MappingBody/Response");
|
||||||
break;
|
break;
|
||||||
case ContentType.Json:
|
case ContentType.Json:
|
||||||
case ContentType.Xml:
|
case ContentType.Xml:
|
||||||
@ -397,6 +397,8 @@ public class InterfaceService : ApplicationService
|
|||||||
switch (input.ContentType)
|
switch (input.ContentType)
|
||||||
{
|
{
|
||||||
case ContentType.None:
|
case ContentType.None:
|
||||||
|
await ParameterService.CreateParametersAsync(input.MappingBodyParameterList, interfaceId, true,
|
||||||
|
ParameterParaKind.MappingBody);
|
||||||
break;
|
break;
|
||||||
case ContentType.Json:
|
case ContentType.Json:
|
||||||
case ContentType.Xml:
|
case ContentType.Xml:
|
||||||
@ -420,6 +422,8 @@ public class InterfaceService : ApplicationService
|
|||||||
switch (input.ContentType)
|
switch (input.ContentType)
|
||||||
{
|
{
|
||||||
case ContentType.None:
|
case ContentType.None:
|
||||||
|
await ParameterService.MaintainParametersAsync(input.MappingBodyParameterList, interfaceId, true,
|
||||||
|
ParameterParaKind.MappingBody);
|
||||||
break;
|
break;
|
||||||
case ContentType.Json:
|
case ContentType.Json:
|
||||||
case ContentType.Xml:
|
case ContentType.Xml:
|
||||||
|
|||||||
@ -217,12 +217,10 @@ ORDER BY `b`.`Sort` ASC").ToListAsync();
|
|||||||
foreach (var map in maps)
|
foreach (var map in maps)
|
||||||
{
|
{
|
||||||
var targetInterface = targetInterfaceList.First(x => map.DownStreamCode == x.Code);
|
var targetInterface = targetInterfaceList.First(x => map.DownStreamCode == x.Code);
|
||||||
var paraKind = targetInterface.ContentType == ContentType.FormUrlEncoded
|
var paraKind = targetInterface.ContentType is ContentType.FormUrlEncoded or ContentType.None
|
||||||
? ParameterParaKind.MappingBody
|
? ParameterParaKind.MappingBody
|
||||||
: ParameterParaKind.Normal;
|
: ParameterParaKind.Normal;
|
||||||
var inParaMaps = targetInterface.ContentType == ContentType.None
|
var inParaMaps = await GetParameterMapListAsync([map.Id], true, paraKind);
|
||||||
? []
|
|
||||||
: await GetParameterMapListAsync([map.Id], true, paraKind);
|
|
||||||
var items = inParaMaps.Where(x => x.InterfaceId == targetInterface.Id).ToList();
|
var items = inParaMaps.Where(x => x.InterfaceId == targetInterface.Id).ToList();
|
||||||
var fixedFieldList = await GetAllFixedFieldListAsync(serviceProvider.Id, targetInterface.Id);
|
var fixedFieldList = await GetAllFixedFieldListAsync(serviceProvider.Id, targetInterface.Id);
|
||||||
|
|
||||||
|
|||||||
@ -69,6 +69,33 @@ public class DefaultForwardFlowTests
|
|||||||
Assert.Null(message.Content);
|
Assert.Null(message.Content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void ReplacePlaceholder_ShouldReplaceQueryFromMappingBodyForNoneContentType()
|
||||||
|
{
|
||||||
|
var flow = new TestForwardFlow();
|
||||||
|
var context = new ForwardCoreContext
|
||||||
|
{
|
||||||
|
TargetInterface = new InterfaceDto
|
||||||
|
{
|
||||||
|
ContentType = ContentType.None,
|
||||||
|
RequestAddress = "https://example.com/callback"
|
||||||
|
},
|
||||||
|
OriginalInterfaceMappedInput = new JObject { ["orderId"] = "A001" },
|
||||||
|
QueryFieldList =
|
||||||
|
[
|
||||||
|
new InterfaceFormFieldDto
|
||||||
|
{
|
||||||
|
Name = "notifyBizEventDTO",
|
||||||
|
Value = GlobalConst.FromMappingBody
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
flow.ReplacePlaceholder(context);
|
||||||
|
|
||||||
|
Assert.Equal("{\"orderId\":\"A001\"}", Assert.Single(context.QueryFieldList).Value);
|
||||||
|
}
|
||||||
|
|
||||||
class TestForwardFlow : DefaultForwardFlow
|
class TestForwardFlow : DefaultForwardFlow
|
||||||
{
|
{
|
||||||
public void SetContentTypeForTest(ForwardCoreContext context, HttpRequestMessage message)
|
public void SetContentTypeForTest(ForwardCoreContext context, HttpRequestMessage message)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user