// 配置服务

import { logger } from '../utils/logger';

// 获取数据源列表
export const fetchDataSources = async () => {
  // 模拟API请求延迟
  await new Promise(resolve => setTimeout(resolve, 200));
  
  return [
    { id: 1, name: 'Wind', status: 'online', priority: 1, enabled: true },
    { id: 2, name: '同花顺', status: 'online', priority: 2, enabled: true },
    { id: 3, name: '东方财富', status: 'online', priority: 3, enabled: true },
    { id: 4, name: '新浪财经', status: 'offline', priority: 4, enabled: false },
    { id: 5, name: 'TQSDK', status: 'online', priority: 5, enabled: true },
    { id: 6, name: 'RQData', status: 'online', priority: 6, enabled: true }
  ];
};

// 保存数据源配置
export const saveDataSource = async (data: any) => {
  // 模拟API请求延迟
  await new Promise(resolve => setTimeout(resolve, 300));
  logger.log('保存数据源配置:', data);
  return data;
};

// 获取AI模型列表
export const fetchAIModels = async () => {
  // 模拟API请求延迟
  await new Promise(resolve => setTimeout(resolve, 200));
  
  return [
    { id: 1, name: 'DeepSeek', accuracy: '85%', responseTime: '250ms', enabled: true },
    { id: 2, name: 'GPT-4', accuracy: '88%', responseTime: '350ms', enabled: false },
    { id: 3, name: 'Claude', accuracy: '82%', responseTime: '200ms', enabled: false },
    { id: 4, name: '自定义模型', accuracy: '78%', responseTime: '150ms', enabled: false }
  ];
};

// 保存AI模型配置
export const saveAIModel = async (data: any) => {
  // 模拟API请求延迟
  await new Promise(resolve => setTimeout(resolve, 300));
  logger.log('保存AI模型配置:', data);
  return data;
};

// 获取系统设置
export const fetchSystemSettings = async () => {
  // 模拟API请求延迟
  await new Promise(resolve => setTimeout(resolve, 100));
  
  return {
    refresh_interval: 30,
    alert_threshold: 70,
    backtest_days: 90
  };
};

// 保存系统设置
export const saveSystemSettings = async (data: any) => {
  // 模拟API请求延迟
  await new Promise(resolve => setTimeout(resolve, 200));
  logger.log('保存系统设置:', data);
  return data;
};