// 系统统计控制器
const systemStatsService = require('../../services/admin/systemStats');

/**
 * 获取系统统计数据
 * @param {import('express').Request} req
 * @param {import('express').Response} res
 * @param {import('express').NextFunction} next
 */
exports.getSystemStats = async (req, res, next) => {
  try {
    const stats = await systemStatsService.getSystemStats();
    
    res.json({
      success: true,
      code: 200,
      message: '获取系统统计数据成功',
      data: stats,
      timestamp: new Date().toISOString()
    });
  } catch (error) {
    next(error);
  }
};

/**
 * 获取用户统计数据
 * @param {import('express').Request} req
 * @param {import('express').Response} res
 * @param {import('express').NextFunction} next
 */
exports.getUserStats = async (req, res, next) => {
  try {
    const stats = await systemStatsService.getUserStats();
    
    res.json({
      success: true,
      code: 200,
      message: '获取用户统计数据成功',
      data: stats,
      timestamp: new Date().toISOString()
    });
  } catch (error) {
    next(error);
  }
};

/**
 * 获取订单统计数据
 * @param {import('express').Request} req
 * @param {import('express').Response} res
 * @param {import('express').NextFunction} next
 */
exports.getOrderStats = async (req, res, next) => {
  try {
    const stats = await systemStatsService.getOrderStats();
    
    res.json({
      success: true,
      code: 200,
      message: '获取订单统计数据成功',
      data: stats,
      timestamp: new Date().toISOString()
    });
  } catch (error) {
    next(error);
  }
};

/**
 * 获取系统信息
 * @param {import('express').Request} req
 * @param {import('express').Response} res
 * @param {import('express').NextFunction} next
 */
exports.getSystemInfo = async (req, res, next) => {
  try {
    const info = await systemStatsService.getSystemInfo();
    
    res.json({
      success: true,
      code: 200,
      message: '获取系统信息成功',
      data: info,
      timestamp: new Date().toISOString()
    });
  } catch (error) {
    next(error);
  }
};