From 57d21822a83cbca9e1d8782c72b286613669938a Mon Sep 17 00:00:00 2001
From: xiaolipro <2357729423@qq.com>
Date: Sat, 26 Jul 2025 15:00:52 +0800
Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E5=BA=8F=E5=88=97=E5=8C=96?=
=?UTF-8?q?=E5=99=A8=E6=94=B9=E4=B8=BAnewtonsoft=EF=BC=8C=E5=8F=96?=
=?UTF-8?q?=E6=B6=88=E9=98=9F=E5=88=97=E7=8B=AC=E5=8D=A0=E6=A8=A1=E5=BC=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../InterfaceForward.Api.csproj | 1 +
.../InterfaceForwardApiModule.cs | 2 +
src/InterfaceForward.Api/appsettings.json | 2 +-
.../Rabbit/RabbitClient.cs | 62 ++++++++++++++++++-
4 files changed, 63 insertions(+), 4 deletions(-)
diff --git a/src/InterfaceForward.Api/InterfaceForward.Api.csproj b/src/InterfaceForward.Api/InterfaceForward.Api.csproj
index b7b0256..d1cee39 100644
--- a/src/InterfaceForward.Api/InterfaceForward.Api.csproj
+++ b/src/InterfaceForward.Api/InterfaceForward.Api.csproj
@@ -11,6 +11,7 @@
+
diff --git a/src/InterfaceForward.Api/InterfaceForwardApiModule.cs b/src/InterfaceForward.Api/InterfaceForwardApiModule.cs
index 5bcd6dc..f54647c 100644
--- a/src/InterfaceForward.Api/InterfaceForwardApiModule.cs
+++ b/src/InterfaceForward.Api/InterfaceForwardApiModule.cs
@@ -25,6 +25,8 @@ public class InterfaceForwardApiModule : FakeModule
{
options.ScanApplicationServices();
});
+
+ services.AddMvc().AddNewtonsoftJson();
services.AddFakeSwaggerGen()
.AddFakeExceptionFilter()
diff --git a/src/InterfaceForward.Api/appsettings.json b/src/InterfaceForward.Api/appsettings.json
index 83e47b6..9e05169 100644
--- a/src/InterfaceForward.Api/appsettings.json
+++ b/src/InterfaceForward.Api/appsettings.json
@@ -32,7 +32,7 @@
},
"FeiShuNotice": {
"Title": "InterfaceForward-Dev",
- "Webhook": "https://open.feishu.cn/open-apis/bot/v2/hook/255c44ff-5891-4902-9b6a-6d0250e745f7",
+ "Webhook": "https://open.feishu.cn/open-apis/bot/v2/hook/e5ced977-a616-42ce-8684-c7628e71b35e",
"Timeout": 20
},
"Redis": {
diff --git a/src/InterfaceForward.Application/Rabbit/RabbitClient.cs b/src/InterfaceForward.Application/Rabbit/RabbitClient.cs
index 5937ae0..2a8b0ec 100644
--- a/src/InterfaceForward.Application/Rabbit/RabbitClient.cs
+++ b/src/InterfaceForward.Application/Rabbit/RabbitClient.cs
@@ -19,8 +19,9 @@ public class RabbitClient(
if (!channelAccessor.IsNew) return;
var channel = channelAccessor.Channel;
+ var decl = new DefaultDeclaration(channel);
- consumeOptions.Declaration.Invoke(channel);
+ consumeOptions.Declaration.Invoke(decl);
if (consumeOptions.FetchCount > 0)
{
@@ -82,5 +83,60 @@ public class ConsumeOptions
public bool FailedRequeue { get; set; }
- public Action Declaration { get; set; }
-}
\ No newline at end of file
+ public Action Declaration { get; set; }
+}
+
+
+public interface IDeclaration
+{
+ void QueueDeclare(string queue, bool durable, bool autoDelete = false, bool exclusive = false,
+ IDictionary arguments = null);
+
+ void ExchangeDeclare(string exchange, string type, bool durable, bool autoDelete = false,
+ IDictionary arguments = null);
+
+ void QueueBind(string queue, string exchange, string routingKey,
+ IDictionary arguments = null);
+}
+
+public class DefaultDeclaration : IDeclaration
+{
+ private readonly IModel _chnl;
+
+ // ReSharper disable once ConvertToPrimaryConstructor
+ public DefaultDeclaration(IModel chnl)
+ {
+ _chnl = chnl;
+ }
+
+ public void QueueDeclare(string queue, bool durable, bool autoDelete = false, bool exclusive = false,
+ IDictionary arguments = null)
+ {
+ _chnl.QueueDeclare(
+ queue: queue,
+ durable: durable,
+ autoDelete: autoDelete,
+ exclusive: exclusive,
+ arguments: arguments);
+ }
+
+ public void ExchangeDeclare(string exchange, string type, bool durable, bool autoDelete = false,
+ IDictionary arguments = null)
+ {
+ _chnl.ExchangeDeclare(
+ exchange: exchange,
+ type: type,
+ durable: durable,
+ autoDelete: autoDelete,
+ arguments: arguments);
+ }
+
+ public void QueueBind(string queue, string exchange, string routingKey, IDictionary arguments)
+ {
+ _chnl.QueueBind(
+ queue: queue,
+ exchange: exchange,
+ routingKey: routingKey,
+ arguments: arguments);
+ }
+}