Kanban de oportunidades por etapa (lead, proposta, negociacao, ganho, perdido) com CRUD completo. - API: `FunilModule` com GET/POST/PATCH/DELETE em /funil, escopado por id_empresa + cod_vendedor. - Modelo `Oportunidade` + migration `sar.oportunidades`. Uma oportunidade referencia um cliente do ERP (id_cliente) ou e um prospect livre (nome_prospect / empresa_prospect). - Contrato Zod compartilhado em `funil.contract.ts`. - Web: `FunilPage` com colunas por etapa, entrada no menu do rep e rota /funil. Nota: a UI ainda nao expoe seletor de cliente, entao toda oportunidade criada pela tela nasce como prospect livre; `idCliente` e `idPedido` ja sao suportados no backend, mas ficam inalcancaveis pela interface. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
49 lines
1.1 KiB
TypeScript
49 lines
1.1 KiB
TypeScript
import {
|
|
Body,
|
|
Controller,
|
|
Delete,
|
|
Get,
|
|
HttpCode,
|
|
Param,
|
|
ParseIntPipe,
|
|
Patch,
|
|
Post,
|
|
} from '@nestjs/common';
|
|
import { createZodDto } from 'nestjs-zod';
|
|
import {
|
|
CreateOportunidadeSchema,
|
|
UpdateOportunidadeSchema,
|
|
type FunilResponse,
|
|
type Oportunidade,
|
|
} from '@sar/api-interface';
|
|
import { FunilService } from './funil.service';
|
|
|
|
class CreateDto extends createZodDto(CreateOportunidadeSchema) {}
|
|
class UpdateDto extends createZodDto(UpdateOportunidadeSchema) {}
|
|
|
|
@Controller('funil')
|
|
export class FunilController {
|
|
constructor(private readonly funil: FunilService) {}
|
|
|
|
@Get()
|
|
listar(): Promise<FunilResponse> {
|
|
return this.funil.listar();
|
|
}
|
|
|
|
@Post()
|
|
criar(@Body() dto: CreateDto): Promise<Oportunidade> {
|
|
return this.funil.criar(CreateOportunidadeSchema.parse(dto));
|
|
}
|
|
|
|
@Patch(':id')
|
|
atualizar(@Param('id', ParseIntPipe) id: number, @Body() dto: UpdateDto): Promise<Oportunidade> {
|
|
return this.funil.atualizar(id, UpdateOportunidadeSchema.parse(dto));
|
|
}
|
|
|
|
@Delete(':id')
|
|
@HttpCode(204)
|
|
deletar(@Param('id', ParseIntPipe) id: number): Promise<void> {
|
|
return this.funil.deletar(id);
|
|
}
|
|
}
|