From bfd4fd8e4a05a681ec10a47992294cf752a764c4 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期一, 02 三月 2026 15:10:58 +0800
Subject: [PATCH] 添加Redis服务与缓存增强
---
Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Core/Http/HttpRequestHelper.cs | 21 +++++++++++++++++----
1 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Core/Http/HttpRequestHelper.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Core/Http/HttpRequestHelper.cs
index 74e4acf..62203ce 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Core/Http/HttpRequestHelper.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Core/Http/HttpRequestHelper.cs
@@ -1,5 +1,6 @@
using SqlSugar;
using System.Text;
+using System.Text.Json;
using WIDESEAWCS_Code;
using WIDESEAWCS_Core.Helper;
@@ -166,17 +167,29 @@
/// <summary>
/// 按配置分类发送GET请求
/// </summary>
- public static Task<string> HTTPGetAsync(string category, string? requestContent, string? configKey, int timeOut = 60)
+ public static async Task<WebResponseContent> HTTPGetAsync(string category, string? requestContent, string? configKey, int timeOut = 60)
{
- return SendAsync(requestContent, HttpMethod.Get, category, configKey, "application/json", timeOut);
+ if (string.IsNullOrWhiteSpace(category) || string.IsNullOrWhiteSpace(requestContent) || string.IsNullOrWhiteSpace(configKey))
+ {
+ throw new ArgumentException("传入配置不能为空", nameof(category));
+ }
+ WebResponseContent content = new WebResponseContent();
+ string result = await SendAsync(requestContent, HttpMethod.Get, category, configKey, "application/json", timeOut);
+ return content = JsonSerializer.Deserialize<WebResponseContent>(result) ?? new WebResponseContent { Status = false, Message = "解析响应失败" };
}
/// <summary>
/// 按配置分类发送POST请求
/// </summary>
- public static Task<string> HTTPPostAsync(string category, string? requestContent, string? configKey, int timeOut = 60)
+ public static async Task<WebResponseContent> HTTPPostAsync(string category, string? requestContent, string? configKey, int timeOut = 60)
{
- return SendAsync(requestContent, HttpMethod.Post, category, configKey, "application/json", timeOut);
+ if (string.IsNullOrWhiteSpace(category) || string.IsNullOrWhiteSpace(requestContent) || string.IsNullOrWhiteSpace(configKey))
+ {
+ throw new ArgumentException("传入配置不能为空", nameof(category));
+ }
+ WebResponseContent content = new WebResponseContent();
+ string result = await SendAsync(requestContent, HttpMethod.Post, category, configKey, "application/json", timeOut);
+ return content = JsonSerializer.Deserialize<WebResponseContent>(result) ?? new WebResponseContent { Status = false, Message = "解析响应失败" };
}
}
}
\ No newline at end of file
--
Gitblit v1.9.3