import { Controller, Get, UseGuards } from '@nestjs/common';
import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger';
import { AdminAuthGuard } from '../../common/guards/admin-auth.guard';
import { AdminRolesGuard } from '../../common/guards/admin-roles.guard';
import { AdminRoles } from '../../common/decorators/admin-roles.decorator';
import type { AdminRole } from '../../common/types/admin-role.enum';

@ApiTags('admin-throttle')
@Controller('admin-api/throttle')
@UseGuards(AdminAuthGuard, AdminRolesGuard)
@ApiBearerAuth()
export class AdminThrottleController {
  @Get('status')
  @AdminRoles('SUPER_ADMIN' as AdminRole)
  @ApiOperation({ summary: '限流状态' })
  async status() {
    return {
      rules: [
        { name: 'global', ttl: '60s', limit: 100, desc: '全局 API' },
        { name: 'ai', ttl: '60s', limit: 20, desc: 'AI 接口' },
        { name: 'login', ttl: '60s', limit: 5, desc: '登录接口' },
        { name: 'upload', ttl: '60s', limit: 10, desc: '文件上传' },
      ],
      storage: 'Redis',
      enabled: true,
    };
  }
}
