| | |
| | | using SqlSugar; |
| | | using System.Text; |
| | | using System.Text.Json; |
| | | using WIDESEAWCS_Code; |
| | | using WIDESEAWCS_Core.Helper; |
| | | |
| | |
| | | /// <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 = "解析响应失败" }; |
| | | } |
| | | } |
| | | } |