import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger';
import { Controller, Get, Post, HttpCode, HttpStatus, UseGuards } from '@nestjs/common';
import { AdminDashboardService } from './admin-dashboard.service';
import { AdminAuthGuard } from '../../common/guards/admin-auth.guard';
import { AdminRolesGuard } from '../../common/guards/admin-roles.guard';

@ApiTags('admin-dashboard')
@Controller('admin-api/dashboard')
@UseGuards(AdminAuthGuard, AdminRolesGuard)
export class AdminDashboardController {
  constructor(private readonly adminDashboardService: AdminDashboardService) {}

  @Get('stats')
  @ApiBearerAuth()
  @ApiOperation({ summary: '获取仪表盘统计数据' })
  async getStats() {
    return this.adminDashboardService.getStats();
  }

  @Post('refresh')
  @HttpCode(HttpStatus.OK)
  @ApiBearerAuth()
  @ApiOperation({ summary: '刷新仪表盘缓存' })
  async refresh() {
    return this.adminDashboardService.refreshCache();
  }
}
