import { Controller, Get, Query, UseGuards } from '@nestjs/common';
import { AuditService } from './audit.service';
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';

@Controller('audit')
@UseGuards(JwtAuthGuard)
export class AuditController {
    constructor(private readonly auditService: AuditService) { }

    /**
     * GET /audit/logs
     * Lists audit logs with pagination
     */
    @Get('logs')
    async getLogs(
        @Query('page') page = '1',
        @Query('limit') limit = '50',
        @Query('entity_type') entityType?: string,
        @Query('action') action?: string,
    ) {
        return this.auditService.getLogs({
            page: parseInt(page, 10),
            limit: parseInt(limit, 10),
            entityType,
            action,
        });
    }
}
