import { Controller, Get, Post, Patch, Delete, Body, Param } from '@nestjs/common';
import { FornecedoresService } from './fornecedores.service';

@Controller('fornecedores')
export class FornecedoresController {
  constructor(private svc: FornecedoresService) {}

  @Get() findAll() { return this.svc.findAll(); }
  @Get(':id') findOne(@Param('id') id: string) { return this.svc.findOne(id); }
  @Post() create(@Body() body: any) { return this.svc.create(body); }
  @Patch(':id') update(@Param('id') id: string, @Body() body: any) { return this.svc.update(id, body); }
  @Delete(':id') remove(@Param('id') id: string) { return this.svc.remove(id); }

  @Get(':id/certidoes') certidoes(@Param('id') id: string) { return this.svc.findCertidoes(id); }
  @Post(':id/certidoes') createCertidao(@Param('id') id: string, @Body() body: any) {
    return this.svc.createCertidao({ ...body, fornecedor_id: id });
  }
}
