import { Controller, Get, UseGuards } from '@nestjs/common';
import { MonitoringService } from '../../core/monitoring/MonitoringService';
import { RbacGuard } from '../../core/guards/rbac.guard';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';

@ApiTags('Monitoring')
@ApiBearerAuth()
@Controller('api/monitoring')
export class MonitoringController {
  constructor(private monitoringService: MonitoringService) {}

  /**
   * 获取当前监控指标
   */
  @Get('metrics')
  @UseGuards(RbacGuard)
  async getMetrics() {
    return this.monitoringService.getMetrics();
  }

  /**
   * 手动收集和记录指标
   */
  @Get('collect')
  @UseGuards(RbacGuard)
  async collectMetrics() {
    await this.monitoringService.collectAndRecordMetrics();
    return { success: true, message: '指标收集成功' };
  }
}
