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";
}