Files
PDV/apps/api/src/modules/customer/customer.controller.ts
T
2026-09-30 14:45:10 -05:00

35 lines
1.1 KiB
TypeScript

import { Body, Controller, Delete, Get, Inject, Param, ParseIntPipe, Patch, Post } from "@nestjs/common";
import type { CreateCustomerInput, UpdateCustomerInput } from "../../dtos/customer.dto.js";
import { CUSTOMER_SERVICE } from "./interfaces/customer-service.interface.js";
import type { ICustomerService } from "./interfaces/customer-service.interface.js";
@Controller("customers")
export class CustomerController {
constructor(@Inject(CUSTOMER_SERVICE) private readonly customerService: ICustomerService) {}
@Get()
findAll() {
return this.customerService.findAll();
}
@Get(":id")
findOne(@Param("id", ParseIntPipe) id: number) {
return this.customerService.findById({ id });
}
@Post()
create(@Body() body: CreateCustomerInput) {
return this.customerService.create(body);
}
@Patch(":id")
update(@Param("id", ParseIntPipe) id: number, @Body() body: UpdateCustomerInput) {
return this.customerService.update({ id }, body);
}
@Delete(":id")
remove(@Param("id", ParseIntPipe) id: number) {
return this.customerService.delete({ id });
}
}