Compare commits

..
3 Commits
Author SHA1 Message Date
xrain b04a7c86d7 signQuery body defaultNull 2025-12-18 13:05:05 +08:00
xrain 8759b593db SimApiHttpClientAddServer 2025-12-18 11:28:47 +08:00
xrainandGitHub 5a46a026a7 Update nuget-publish.yml
fix ci
2025-12-18 09:13:19 +08:00
2 changed files with 7 additions and 4 deletions
+3 -3
View File
@@ -10,11 +10,11 @@ jobs:
name: Publish Project to Nuget name: Publish Project to Nuget
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v4
- name: Setup .NET Core - name: Setup .NET Core
uses: actions/setup-dotnet@v1 uses: actions/setup-dotnet@v5
with: with:
dotnet-version: "9.0.305" dotnet-version: "10.x.x"
- name: Publish - name: Publish
run: | run: |
version=`git describe --tags` version=`git describe --tags`
+4 -1
View File
@@ -9,6 +9,7 @@ namespace SimApi.Helpers;
public class SimApiHttpClient(string? appId, string appKey) public class SimApiHttpClient(string? appId, string appKey)
{ {
public string Server { get; init; } = string.Empty;
public string SignName { get; init; } = "sign"; public string SignName { get; init; } = "sign";
public string TimestampName { get; init; } = "timestamp"; public string TimestampName { get; init; } = "timestamp";
public string NonceName { get; init; } = "nonce"; public string NonceName { get; init; } = "nonce";
@@ -16,8 +17,9 @@ public class SimApiHttpClient(string? appId, string appKey)
public string[] SignFields { get; init; } = []; public string[] SignFields { get; init; } = [];
public T? SignQuery<T>(string url, object body, Dictionary<string, string>? queries = null) public T? SignQuery<T>(string url, object? body = null, Dictionary<string, string>? queries = null)
{ {
url = Server + url;
var queryUrl = SignFields.Aggregate(string.Empty, var queryUrl = SignFields.Aggregate(string.Empty,
(current, signField) => current + $"{signField}={queries?[signField]}&"); (current, signField) => current + $"{signField}={queries?[signField]}&");
if (!string.IsNullOrEmpty(AppIdName)) if (!string.IsNullOrEmpty(AppIdName))
@@ -42,6 +44,7 @@ public class SimApiHttpClient(string? appId, string appKey)
public T? AesQuery<T>(string url, object body) public T? AesQuery<T>(string url, object body)
{ {
url = Server + url;
if (!string.IsNullOrEmpty(AppIdName)) if (!string.IsNullOrEmpty(AppIdName))
{ {
url += $"?{AppIdName}={appId}"; url += $"?{AppIdName}={appId}";