import { Body, Controller, Get, Param, Post, Query, UseGuards } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger';
import { ReportsService } from './reports.service';
import { GenerateReportDto } from './reports.dto';
import { IamGuard, IamRoles } from '../../common/iam-adapter';
import { UserRole } from '@prisma/client';

@ApiTags('Reports')
@Controller('reports')
@UseGuards(IamGuard)
@ApiBearerAuth('IAM-auth')
export class ReportsController {
  constructor(private service: ReportsService) {}

  @Post('generate')
  @IamRoles('ADMIN', 'SUPERVISOR')
  @ApiOperation({ summary: 'Generate operational report' })
  generateReport(@Body() dto: GenerateReportDto) {
    return this.service.generateReport(dto);
  }

  @Get(':reportId')
  @IamRoles('ADMIN', 'SUPERVISOR')
  @ApiOperation({ summary: 'Get report by ID' })
  getReport(@Param('reportId') reportId: string) {
    return this.service.getReport(reportId);
  }

  @Get()
  @IamRoles('ADMIN', 'SUPERVISOR')
  @ApiOperation({ summary: 'List reports' })
  listReports(@Query('type') type?: string) {
    return this.service.listReports(type);
  }
}
