Sfoglia il codice sorgente

Merge branch 'feature/snapshot' into test

qinchaoyue 3 mesi fa
parent
commit
66ebb1b48a

+ 11 - 3
src/Hotline.Api/Controllers/ExportData/ExportDataController.cs

@@ -37,15 +37,23 @@ public class ExportDataController : BaseController
         if (string.IsNullOrEmpty(originalPath))
             throw UserFriendlyException.SameMessage("无效的URL地址" + fullPath);
 
-        var matchingEndpoint = _endpointDataSource.Endpoints
+        var matchingEndpoints = _endpointDataSource.Endpoints
             .OfType<RouteEndpoint>()
-            .FirstOrDefault(endpoint => endpoint.RoutePattern.RawText == originalPath) 
+            .Where(endpoint => endpoint.RoutePattern.RawText == originalPath)
+            .ToList()
             ?? throw UserFriendlyException.SameMessage($"根据URL查询路由失败: {originalPath}");
+        var matchingEndpoint = matchingEndpoints.First();
+        if (matchingEndpoints.Count > 1)
+        {
+            matchingEndpoint = matchingEndpoints.First(m => m.DisplayName.Contains("Get"));
+        }
+        if (matchingEndpoint == null)
+            throw UserFriendlyException.SameMessage($"根据URL查询路由失败: {originalPath}");
 
         var controllerName = matchingEndpoint.RoutePattern.RequiredValues["controller"]?.ToString();
         var actionName = matchingEndpoint.RoutePattern.RequiredValues["action"]?.ToString();
 
-        var applicationServiceType = GetApplicationServiceType(controllerName) 
+        var applicationServiceType = GetApplicationServiceType(controllerName)
             ?? throw UserFriendlyException.SameMessage($"根据名称查找方法失败. '{controllerName}'");
 
         var method = applicationServiceType.GetMethod(actionName);