39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
import { Body, Controller, Delete, Get, Param, ParseIntPipe, Patch, Post } from '@nestjs/common';
|
|
import { CustomersService } from '../services/customers.service';
|
|
import { Customers, Employees } from '@prisma/client';
|
|
import { CreateCustomerDto } from '../dtos/create-customer';
|
|
import { UpdateCustomerDto } from '../dtos/update-customer';
|
|
|
|
@Controller('customers')
|
|
export class CustomersController {
|
|
constructor(private readonly customersService: CustomersService) {}
|
|
|
|
@Post()
|
|
create(@Body() dto: CreateCustomerDto): Promise<Customers> {
|
|
return this.customersService.create(dto);
|
|
}
|
|
|
|
@Get()
|
|
findAll(): Promise<Customers[]> {
|
|
return this.customersService.findAll();
|
|
}
|
|
|
|
@Get(':id')
|
|
findOne(@Param('id', ParseIntPipe) id: number): Promise<Customers> {
|
|
return this.customersService.findOne(id);
|
|
}
|
|
|
|
@Patch(':id')
|
|
update(
|
|
@Param('id', ParseIntPipe) id: number,
|
|
@Body() dto: UpdateCustomerDto,
|
|
): Promise<Customers> {
|
|
return this.customersService.update(id, dto);
|
|
}
|
|
|
|
@Delete(':id')
|
|
remove(@Param('id', ParseIntPipe) id: number): Promise<Customers>{
|
|
return this.customersService.remove(id);
|
|
}
|
|
}
|