From 658cfe90e11c91b980c0496cc7f13402c446a503 Mon Sep 17 00:00:00 2001 From: claw_bot Date: Mon, 9 Mar 2026 09:39:02 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=A7=BB=E9=99=A4=E6=89=80=E6=9C=89ICon?= =?UTF-8?q?figuration=E4=BE=9D=E8=B5=96=EF=BC=8C=E5=AE=8C=E5=85=A8?= =?UTF-8?q?=E4=BB=8E=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F=E8=AF=BB=E5=8F=96?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=EF=BC=8C=E8=A7=A3=E5=86=B3=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AssetManager.Infrastructure/Services/MarketDataService.cs | 5 ++--- AssetManager.Services/Services/JwtService.cs | 8 ++------ AssetManager.Services/Services/WechatService.cs | 7 ++----- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/AssetManager.Infrastructure/Services/MarketDataService.cs b/AssetManager.Infrastructure/Services/MarketDataService.cs index 2f62bdf..fd11dc4 100644 --- a/AssetManager.Infrastructure/Services/MarketDataService.cs +++ b/AssetManager.Infrastructure/Services/MarketDataService.cs @@ -19,14 +19,13 @@ public class MarketDataService : IMarketDataService /// /// 日志记录器 /// HTTP 客户端工厂 - public MarketDataService(ILogger logger, IHttpClientFactory httpClientFactory, IConfiguration configuration) + public MarketDataService(ILogger logger, IHttpClientFactory httpClientFactory) { _logger = logger; _httpClient = httpClientFactory.CreateClient(); - // 优先从环境变量读取 Tiingo API Key + // 完全从环境变量读取 Tiingo API Key _tiingoApiKey = Environment.GetEnvironmentVariable("Tiingo__ApiKey") ?? Environment.GetEnvironmentVariable("TIINGO_API_KEY") - ?? configuration["Tiingo:ApiKey"] ?? "bd00fee76d3012b047473078904001b33322cb46"; _httpClient.DefaultRequestHeaders.Add("Authorization", $"Token {_tiingoApiKey}"); } diff --git a/AssetManager.Services/Services/JwtService.cs b/AssetManager.Services/Services/JwtService.cs index 7df2917..eb67ecb 100644 --- a/AssetManager.Services/Services/JwtService.cs +++ b/AssetManager.Services/Services/JwtService.cs @@ -1,4 +1,3 @@ -using Microsoft.Extensions.Configuration; using Microsoft.IdentityModel.Tokens; using System.IdentityModel.Tokens.Jwt; using System.Security.Claims; @@ -12,19 +11,16 @@ public class JwtService private readonly string _issuer; private readonly string _audience; - public JwtService(IConfiguration configuration) + public JwtService() { - // 优先从环境变量读取 + // 完全从环境变量读取 _secretKey = Environment.GetEnvironmentVariable("Jwt__SecretKey") - ?? configuration["Jwt:SecretKey"] ?? "your-strong-secret-key-here-2026"; _issuer = Environment.GetEnvironmentVariable("Jwt__Issuer") - ?? configuration["Jwt:Issuer"] ?? "AssetManager"; _audience = Environment.GetEnvironmentVariable("Jwt__Audience") - ?? configuration["Jwt:Audience"] ?? "AssetManager"; } diff --git a/AssetManager.Services/Services/WechatService.cs b/AssetManager.Services/Services/WechatService.cs index 444f724..e180df6 100644 --- a/AssetManager.Services/Services/WechatService.cs +++ b/AssetManager.Services/Services/WechatService.cs @@ -1,7 +1,6 @@ using System.Net.Http; using System.Text.Json; using System.Threading.Tasks; -using Microsoft.Extensions.Configuration; namespace AssetManager.Services.Services; @@ -11,16 +10,14 @@ public class WechatService private readonly string _appId; private readonly string _appSecret; - public WechatService(HttpClient httpClient, IConfiguration configuration) + public WechatService(HttpClient httpClient) { _httpClient = httpClient; - // 优先从环境变量读取 + // 完全从环境变量读取 _appId = Environment.GetEnvironmentVariable("Wechat__AppId") - ?? configuration["Wechat:AppId"] ?? "wx245f0f3ebcfcf5a7"; _appSecret = Environment.GetEnvironmentVariable("Wechat__AppSecret") - ?? configuration["Wechat:AppSecret"] ?? "809c740129bc8b434177ce12ef292dd0"; }