/**
 * 数据统计模块 Swagger 文档
 * @file swagger-stats.js
 * @description 数据统计相关的 Swagger API 文档定义
 */

// 数据统计相关的 API 路径定义
const statsPaths = {
  '/api/stats/dashboard': {
    get: {
      summary: '获取仪表盘统计数据',
      tags: ['数据统计'],
      responses: {
        200: { $ref: '#/components/responses/Success' }
      }
    }
  },
  '/api/stats/monitoring': {
    get: {
      summary: '获取监控数据',
      tags: ['数据统计'],
      responses: {
        200: { $ref: '#/components/responses/Success' }
      }
    }
  },
  '/api/stats/monthly-trends': {
    get: {
      summary: '获取月度数据趋势',
      tags: ['数据统计'],
      parameters: [
        {
          name: 'startDate',
          in: 'query',
          schema: { type: 'string', format: 'date' },
          description: '开始日期'
        },
        {
          name: 'endDate',
          in: 'query',
          schema: { type: 'string', format: 'date' },
          description: '结束日期'
        }
      ],
      responses: {
        200: { $ref: '#/components/responses/Success' }
      }
    }
  },
  '/api/stats/farm-count': {
    get: {
      summary: '获取养殖场总数统计',
      tags: ['数据统计'],
      responses: {
        200: { $ref: '#/components/responses/Success' }
      }
    }
  },
  '/api/stats/animal-count': {
    get: {
      summary: '获取动物总数统计',
      tags: ['数据统计'],
      responses: {
        200: { $ref: '#/components/responses/Success' }
      }
    }
  }
};

// 数据统计相关的数据模型定义
const statsSchemas = {
  DashboardStats: {
    type: 'object',
    properties: {
      totalFarms: { type: 'integer', description: '养殖场总数' },
      totalAnimals: { type: 'integer', description: '动物总数' },
      totalDevices: { type: 'integer', description: '设备总数' },
      activeAlerts: { type: 'integer', description: '活跃预警数' },
      onlineDevices: { type: 'integer', description: '在线设备数' },
      offlineDevices: { type: 'integer', description: '离线设备数' }
    }
  },
  MonthlyTrend: {
    type: 'object',
    properties: {
      month: { type: 'string', description: '月份' },
      farms: { type: 'integer', description: '养殖场数量' },
      animals: { type: 'integer', description: '动物数量' },
      devices: { type: 'integer', description: '设备数量' }
    }
  }
};

module.exports = {
  statsPaths,
  statsSchemas
};

