import {
  Controller,
  Get,
  Post,
  Body,
  HttpCode,
  HttpStatus,
} from '@nestjs/common';
import { EvolutionService } from '../../application/services/evolution.service';
import { RunEvolutionTaskDto } from '../../application/dtos/evolution.dto';

@Controller('evolution')
export class EvolutionController {
  constructor(private evolutionService: EvolutionService) {}

  /**
   * 手动触发进化任务
   */
  @Post('run')
  @HttpCode(HttpStatus.OK)
  async runEvolutionTask(@Body() dto: RunEvolutionTaskDto) {
    const result = await this.evolutionService.runEvolutionTask(dto);
    return {
      success: true,
      data: result,
    };
  }

  /**
   * 获取进化统计信息
   */
  @Get('statistics')
  async getStatistics() {
    const stats = await this.evolutionService.getEvolutionStatistics();
    return {
      success: true,
      data: stats,
    };
  }

  /**
   * 获取系统健康报告
   */
  @Get('health')
  async getHealthReport() {
    const report = await this.evolutionService.getSystemHealthReport();
    return {
      success: true,
      data: report,
    };
  }
}
