From a203c86aa18dff66f07159a7ae5fefc318b43162 Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期五, 05 九月 2025 14:13:12 +0800
Subject: [PATCH] fix: s

---
 FlexJobApi.CommonServer.Application/LogRecords/Commands/ResendResourceCommandHandler.cs |   28 ++++++++++++++++++++++++----
 1 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/FlexJobApi.CommonServer.Application/LogRecords/Commands/ResendResourceCommandHandler.cs b/FlexJobApi.CommonServer.Application/LogRecords/Commands/ResendResourceCommandHandler.cs
index 17662b7..396b1bb 100644
--- a/FlexJobApi.CommonServer.Application/LogRecords/Commands/ResendResourceCommandHandler.cs
+++ b/FlexJobApi.CommonServer.Application/LogRecords/Commands/ResendResourceCommandHandler.cs
@@ -7,6 +7,7 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
+using System.Net;
 using System.Text;
 using System.Threading.Tasks;
 
@@ -17,14 +18,12 @@
     /// </summary>
     public class ResendResourceCommandHandler(
             IRepository<ResourceLog, LogDbContextLocator> repResourceLog,
-            IRepository<Resource> repResource,
-            ResourceHttpUtils resourceHttpUtils
+            IRepository<Resource> repResource
         ) :
         IRequestHandler<ResendResourceCommand, string>
     {
         private readonly IRepository<ResourceLog, LogDbContextLocator> repResourceLog = repResourceLog;
         private readonly IRepository<Resource> repResource = repResource;
-        private readonly ResourceHttpUtils resourceHttpUtils = resourceHttpUtils;
 
         /// <summary>
         /// 閲嶆柊鍙戦�佽祫婧�
@@ -40,6 +39,7 @@
                 {
                     it.Method,
                     it.Path,
+                    it.RequestHeaders,
                     it.Request,
                     it.CreatedUserId
                 })
@@ -47,7 +47,14 @@
             if (log == null) throw Oops.Oh(EnumErrorCodeType.s404, "鏃ュ織");
             var resource = await repResource.AsQueryable().AsNoTracking()
                 .Where(it => it.Method == log.Method && it.Route == log.Path)
+                .Select(it => new
+                {
+                    it.ServiceName,
+                    it.Route,
+                    it.Method
+                })
                 .FirstOrDefaultAsync();
+            if (resource == null) throw Oops.Oh(EnumErrorCodeType.s404, "璧勬簮");
             var paramters = log.Request
                 .JsonTo(new
                 {
@@ -55,7 +62,20 @@
                 })
                 .request
                 .ToJson();
-            var result = await resourceHttpUtils.SendHttpAsync(resource, paramters);
+            string? accessToken = null, refreshToken = null;
+            if (log.RequestHeaders.IsNotNull())
+            {
+                var headers = log.RequestHeaders.JsonTo<Dictionary<string, List<string>>>();
+                if (headers.ContainsKey("Authorization"))
+                {
+                    accessToken = headers["Authorization"].FirstOrDefault();
+                }
+                if (headers.ContainsKey("X-Authorization"))
+                {
+                    refreshToken = headers["X-Authorization"].FirstOrDefault();
+                }
+            }
+            var result = await paramters.SendHttpAsync(resource.ServiceName, resource.Route, resource.Method, accessToken: accessToken, refreshToken: refreshToken);
             return result;
         }
     }

--
Gitblit v1.9.1