From 9b28998dcc9b446dfe2e21f3de6113e5d1a985a7 Mon Sep 17 00:00:00 2001
From: xiaolipro <2357729423@qq.com>
Date: Tue, 2 Dec 2025 17:18:57 +0800
Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E9=87=8D=E5=91=BD=E5=90=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../ForwardCore/IInterfaceForwardService.cs | 38 --------------
.../InterfaceRelayUnifyResultDto.cs | 6 +--
.../Filters/ForwardAuthorizeFilter.cs | 2 +-
.../Filters/ForwardExceptionFilter.cs | 10 ++--
.../ShopeeForwardExceptionFilter.cs | 10 ++--
.../Services/InterfaceForwardService.cs | 50 +++++++++----------
6 files changed, 39 insertions(+), 77 deletions(-)
delete mode 100644 src/InterfaceForward.Application.Contracts/ForwardCore/IInterfaceForwardService.cs
diff --git a/src/InterfaceForward.Application.Contracts/ForwardCore/IInterfaceForwardService.cs b/src/InterfaceForward.Application.Contracts/ForwardCore/IInterfaceForwardService.cs
deleted file mode 100644
index b2c2c66..0000000
--- a/src/InterfaceForward.Application.Contracts/ForwardCore/IInterfaceForwardService.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-namespace InterfaceForward.Application.Contracts.ForwardCore;
-
-///
-/// 接口通转发服务
-///
-public interface IInterfaceForwardService
-{
- ///
- /// 转发请求
- ///
- ///
- /// 请求头、公共参数、基本配置、结构定义、映射啥的去接口通配
- ///
- /// 系统接口code
- /// 服务商code
- /// body
- /// 额外信息,原样返回
- /// 是否返回原报文
- /// 失败推送订阅名,不填就不推
- ///
- Task ForwardWithSubscribeAsync(string upStreamCode, string serviceProviderCode,
- object data, string? attach = null, bool isReturnMessage = false, string? failedSubscribeName = null);
-
- ///
- /// 重新请求(一对多的情况下调用)
- ///
- /// 系统接口code
- /// 服务商code
- /// 请求id
- /// body
- /// 额外信息,原样返回
- /// 是否返回原报文
- /// 失败推送订阅名,不填就不推
- ///
- Task ReForwardAsync(string upStreamCode, string serviceProviderCode,
- Guid requestId, object data, string? attach = null,
- bool isReturnMessage = false, string? failedSubscribeName = null);
-}
\ No newline at end of file
diff --git a/src/InterfaceForward.Application.Contracts/ForwardCore/InterfaceRelayUnifyResultDto.cs b/src/InterfaceForward.Application.Contracts/ForwardCore/InterfaceRelayUnifyResultDto.cs
index b2950eb..1aae2b5 100644
--- a/src/InterfaceForward.Application.Contracts/ForwardCore/InterfaceRelayUnifyResultDto.cs
+++ b/src/InterfaceForward.Application.Contracts/ForwardCore/InterfaceRelayUnifyResultDto.cs
@@ -22,15 +22,15 @@ public class InterfaceRelayUnifyResultDto
///
/// 请求Id
///
- public Guid RequestId { get; set; }
+ public Guid RqId { get; set; }
///
/// 原报文
///
- public string? OriginalMessage { get; set; }
+ public string? SourceData { get; set; }
///
/// 附加数据
///
- public string? Attach { get; set; }
+ public string? Other { get; set; }
}
\ No newline at end of file
diff --git a/src/InterfaceForward.Application/Filters/ForwardAuthorizeFilter.cs b/src/InterfaceForward.Application/Filters/ForwardAuthorizeFilter.cs
index 499f694..47cd239 100644
--- a/src/InterfaceForward.Application/Filters/ForwardAuthorizeFilter.cs
+++ b/src/InterfaceForward.Application/Filters/ForwardAuthorizeFilter.cs
@@ -57,7 +57,7 @@ public class ForwardAuthorizeFilter(
logRepository.AppId = app.Id;
- var upStreamCode = httpContext.Request.Query["upStreamCode"].ToString();
+ var upStreamCode = httpContext.Request.Query["standardCode"].ToString();
var systemInterface = await interfaceRepository.GetFirstAsync(x => x.Code == upStreamCode,
x => new { x.Code, x.Name });
if (systemInterface == null) throw new BusinessException(message: "系统接口不存在");
diff --git a/src/InterfaceForward.Application/Filters/ForwardExceptionFilter.cs b/src/InterfaceForward.Application/Filters/ForwardExceptionFilter.cs
index b5d10d5..85cfbfb 100644
--- a/src/InterfaceForward.Application/Filters/ForwardExceptionFilter.cs
+++ b/src/InterfaceForward.Application/Filters/ForwardExceptionFilter.cs
@@ -25,7 +25,7 @@ public class ForwardExceptionFilter(
* ServiceProviderRequestLog设计的意义是:
* 最大可能限度的保留请求服务商发生异常时附近的日志信息,以便于排查问题
*/
- var originMessage = bool.TryParse(context.HttpContext.Request.Headers["isReturnMessage"].ToString(),
+ var originMessage = bool.TryParse(context.HttpContext.Request.Headers["sourceData"].ToString(),
out var isReturnMessage)
? isReturnMessage ? logRepository.ServiceProviderRequestLog.Response : null
: null;
@@ -33,9 +33,9 @@ public class ForwardExceptionFilter(
var res = new InterfaceRelayUnifyResultDto
{
Code = StatusCodes.Status400BadRequest.ToString(),
- RequestId = logRepository.AppRequestLog.RequestId,
- OriginalMessage = originMessage,
- Attach = context.HttpContext.Request.Headers["attach"]
+ RqId = logRepository.AppRequestLog.RequestId,
+ SourceData = originMessage,
+ Other = context.HttpContext.Request.Headers["other"]
};
if (context.Exception is ValidationException errors) //验证异常
@@ -71,7 +71,7 @@ public class ForwardExceptionFilter(
private bool NeedPush(ExceptionContext context, out string subscribeName)
{
subscribeName = null;
- string interfaceCode = context.HttpContext.Request.Query["upStreamCode"];
+ string interfaceCode = context.HttpContext.Request.Query["standardCode"];
subscribeName = context.HttpContext.Request.Headers["failedSubscribeName"];
return _options.FailedNeedPush.Contains(interfaceCode) && !subscribeName.IsNullOrWhiteSpace();
diff --git a/src/InterfaceForward.Application/Services/Customized/ShopeeForwardExceptionFilter.cs b/src/InterfaceForward.Application/Services/Customized/ShopeeForwardExceptionFilter.cs
index 1a544f7..817821a 100644
--- a/src/InterfaceForward.Application/Services/Customized/ShopeeForwardExceptionFilter.cs
+++ b/src/InterfaceForward.Application/Services/Customized/ShopeeForwardExceptionFilter.cs
@@ -25,7 +25,7 @@ public class ShopeeForwardExceptionFilter(
* ServiceProviderRequestLog设计的意义是:
* 最大可能限度的保留请求服务商发生异常时附近的日志信息,以便于排查问题
*/
- var originMessage = bool.TryParse(context.HttpContext.Request.Headers["isReturnMessage"].ToString(),
+ var originMessage = bool.TryParse(context.HttpContext.Request.Headers["sourceData"].ToString(),
out var isReturnMessage)
? isReturnMessage ? logRepository.ServiceProviderRequestLog.Response : null
: null;
@@ -33,9 +33,9 @@ public class ShopeeForwardExceptionFilter(
var res = new InterfaceRelayUnifyResultDto
{
Code = StatusCodes.Status400BadRequest.ToString(),
- RequestId = logRepository.AppRequestLog.RequestId,
- OriginalMessage = originMessage,
- Attach = context.HttpContext.Request.Headers["attach"]
+ RqId = logRepository.AppRequestLog.RequestId,
+ SourceData = originMessage,
+ Other = context.HttpContext.Request.Headers["other"]
};
if (context.Exception is ValidationException errors) //验证异常
@@ -71,7 +71,7 @@ public class ShopeeForwardExceptionFilter(
private bool NeedPush(ExceptionContext context, out string subscribeName)
{
subscribeName = null;
- string interfaceCode = context.HttpContext.Request.Query["upStreamCode"];
+ string interfaceCode = context.HttpContext.Request.Query["standardCode"];
subscribeName = context.HttpContext.Request.Headers["failedSubscribeName"];
return _options.FailedNeedPush.Contains(interfaceCode) && !subscribeName.IsNullOrWhiteSpace();
diff --git a/src/InterfaceForward.Application/Services/InterfaceForwardService.cs b/src/InterfaceForward.Application/Services/InterfaceForwardService.cs
index efc99b7..27858ba 100644
--- a/src/InterfaceForward.Application/Services/InterfaceForwardService.cs
+++ b/src/InterfaceForward.Application/Services/InterfaceForwardService.cs
@@ -20,7 +20,7 @@ namespace InterfaceForward.Application.Services;
[TypeFilter(typeof(ForwardAuthorizeFilter))]
[TypeFilter(typeof(ForwardExceptionFilter))]
[AllowAnonymous]
-public class InterfaceForwardService : ApplicationService, IInterfaceForwardService
+public class InterfaceForwardService : ApplicationService
{
private readonly InterfaceForwardCommon _forwardCommon;
private readonly ILogRepository _logRepository;
@@ -37,31 +37,31 @@ public class InterfaceForwardService : ApplicationService, IInterfaceForwardServ
_httpContextAccessor = httpContextAccessor;
}
- [HttpPost("InterfaceForward/BatchForwardThenPushToQueue")]
+ [HttpPost("Itfx/BatchRequest")]
public async Task BatchForwardThenPushToQueueAsync(
- [FromQuery] [Required] string upStreamCode,
- [FromQuery] [Required] string serviceProviderCode,
+ [FromQuery] [Required] string standardCode,
+ [FromQuery] [Required] string supplierCode,
[FromBody] [Required] List