fix:none

This commit is contained in:
xiaolipro 2026-06-05 14:50:40 +08:00
parent df9afe876b
commit 0202800d7a
4 changed files with 38 additions and 7 deletions

View File

@ -584,7 +584,9 @@ public class DefaultForwardFlow : IForwardFlow, ITransientDependency
GlobalConst.DateTime => TurnDate(now, description),
GlobalConst.Url => context.TargetInterface.RequestAddress,
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
};
}

View File

@ -367,8 +367,8 @@ public class InterfaceService : ApplicationService
switch (input.ContentType)
{
case ContentType.None:
if (input.InParameterList.Count > 0 || input.RequestBodyParameterList.Count > 0 || input.MappingBodyParameterList.Count > 0 || input.BodyFormParameterList.Count > 0)
throw new BusinessException(message: "None 下游接口只能维护 Query/Header/Response");
if (input.InParameterList.Count > 0 || input.RequestBodyParameterList.Count > 0 || input.BodyFormParameterList.Count > 0)
throw new BusinessException(message: "None 下游接口只能维护 Query/Header/MappingBody/Response");
break;
case ContentType.Json:
case ContentType.Xml:
@ -397,6 +397,8 @@ public class InterfaceService : ApplicationService
switch (input.ContentType)
{
case ContentType.None:
await ParameterService.CreateParametersAsync(input.MappingBodyParameterList, interfaceId, true,
ParameterParaKind.MappingBody);
break;
case ContentType.Json:
case ContentType.Xml:
@ -420,6 +422,8 @@ public class InterfaceService : ApplicationService
switch (input.ContentType)
{
case ContentType.None:
await ParameterService.MaintainParametersAsync(input.MappingBodyParameterList, interfaceId, true,
ParameterParaKind.MappingBody);
break;
case ContentType.Json:
case ContentType.Xml:

View File

@ -217,12 +217,10 @@ ORDER BY `b`.`Sort` ASC").ToListAsync();
foreach (var map in maps)
{
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.Normal;
var inParaMaps = targetInterface.ContentType == ContentType.None
? []
: await GetParameterMapListAsync([map.Id], true, paraKind);
var inParaMaps = await GetParameterMapListAsync([map.Id], true, paraKind);
var items = inParaMaps.Where(x => x.InterfaceId == targetInterface.Id).ToList();
var fixedFieldList = await GetAllFixedFieldListAsync(serviceProvider.Id, targetInterface.Id);

View File

@ -69,6 +69,33 @@ public class DefaultForwardFlowTests
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
{
public void SetContentTypeForTest(ForwardCoreContext context, HttpRequestMessage message)