import express from 'express';
import { fetchAIAnalysis, fetchMultiDimensionAnalysis, fetchTrendPrediction, fetchWinRateAssessment, fetchTechnicalIndicators } from '../services/analysisService';

const router = express.Router();

// 获取AI分析
router.get('/ai/:symbol', async (req, res) => {
  try {
    const { symbol } = req.params;
    const data = await fetchAIAnalysis(symbol);
    res.status(200).json({ success: true, data });
  } catch (error) {
    res.status(500).json({ success: false, message: '获取AI分析失败' });
  }
});

// 获取多维度分析
router.get('/multi/:symbol', async (req, res) => {
  try {
    const { symbol } = req.params;
    const data = await fetchMultiDimensionAnalysis(symbol);
    res.status(200).json({ success: true, data });
  } catch (error) {
    res.status(500).json({ success: false, message: '获取多维度分析失败' });
  }
});

// 获取趋势预测
router.get('/trend/:symbol', async (req, res) => {
  try {
    const { symbol } = req.params;
    const data = await fetchTrendPrediction(symbol);
    res.status(200).json({ success: true, data });
  } catch (error) {
    res.status(500).json({ success: false, message: '获取趋势预测失败' });
  }
});

// 获取胜率评估
router.get('/winrate/:symbol', async (req, res) => {
  try {
    const { symbol } = req.params;
    const data = await fetchWinRateAssessment(symbol);
    res.status(200).json({ success: true, data });
  } catch (error) {
    res.status(500).json({ success: false, message: '获取胜率评估失败' });
  }
});

// 获取技术指标
router.get('/indicators/:symbol', async (req, res) => {
  try {
    const { symbol } = req.params;
    const data = await fetchTechnicalIndicators(symbol);
    res.status(200).json({ success: true, data });
  } catch (error) {
    res.status(500).json({ success: false, message: '获取技术指标失败' });
  }
});

export default router;