refactor: 使用FileManager统一文件操作
将分散在各处的文件操作统一封装到FileManager工具类中,包括文件读写、目录创建、JSON处理等操作
This commit is contained in:
@@ -19,22 +19,22 @@ class FundAdminAPI extends ApiBase {
|
||||
FileManager::ensureDirExists('data');
|
||||
|
||||
// 初始化配置文件(如果不存在)
|
||||
if (!file_exists($this->configFile)) {
|
||||
if (!FileManager::fileExists($this->configFile)) {
|
||||
$this->initConfig();
|
||||
}
|
||||
|
||||
// 初始化操作日志文件(如果不存在)
|
||||
if (!file_exists($this->operationFile)) {
|
||||
if (!FileManager::fileExists($this->operationFile)) {
|
||||
$this->initOperationLog();
|
||||
}
|
||||
|
||||
// 初始化基金名称文件(如果不存在)
|
||||
if (!file_exists($this->fundNamesFile)) {
|
||||
if (!FileManager::fileExists($this->fundNamesFile)) {
|
||||
$this->initFundNames();
|
||||
}
|
||||
|
||||
// 初始化推荐基金文件(如果不存在)
|
||||
if (!file_exists($this->recommendedFundsFile)) {
|
||||
if (!FileManager::fileExists($this->recommendedFundsFile)) {
|
||||
$this->initRecommendedFunds();
|
||||
}
|
||||
}
|
||||
@@ -142,7 +142,7 @@ class FundAdminAPI extends ApiBase {
|
||||
* 加载基金名称映射
|
||||
*/
|
||||
private function loadFundNames() {
|
||||
if (!file_exists($this->fundNamesFile)) {
|
||||
if (!FileManager::fileExists($this->fundNamesFile)) {
|
||||
$this->initFundNames();
|
||||
}
|
||||
|
||||
@@ -719,7 +719,7 @@ class FundAdminAPI extends ApiBase {
|
||||
]
|
||||
]);
|
||||
|
||||
$response = file_get_contents($apiUrl, false, $context);
|
||||
$response = FileManager::loadFile($apiUrl);
|
||||
|
||||
if ($response) {
|
||||
// 处理不同API的响应格式
|
||||
|
||||
Reference in New Issue
Block a user