54 lines
1.1 KiB
TypeScript
54 lines
1.1 KiB
TypeScript
import {
|
|
Body,
|
|
Controller,
|
|
Delete,
|
|
Get,
|
|
Inject,
|
|
Param,
|
|
ParseIntPipe,
|
|
Patch,
|
|
Post,
|
|
} from "@nestjs/common";
|
|
import type {
|
|
CreateSupplierInput,
|
|
UpdateSupplierInput,
|
|
} from "../../dtos/supplier.dto.js";
|
|
import { SUPPLIER_SERVICE } from "./interfaces/supplier-service.interface.js";
|
|
import type { ISupplierService } from "./interfaces/supplier-service.interface.js";
|
|
|
|
@Controller("suppliers")
|
|
export class SupplierController {
|
|
constructor(
|
|
@Inject(SUPPLIER_SERVICE)
|
|
private readonly supplierService: ISupplierService,
|
|
) {}
|
|
|
|
@Get()
|
|
findAll() {
|
|
return this.supplierService.findAll();
|
|
}
|
|
|
|
@Get(":id")
|
|
findOne(@Param("id", ParseIntPipe) id: number) {
|
|
return this.supplierService.findById({ id });
|
|
}
|
|
|
|
@Post()
|
|
create(@Body() body: CreateSupplierInput) {
|
|
return this.supplierService.create(body);
|
|
}
|
|
|
|
@Patch(":id")
|
|
update(
|
|
@Param("id", ParseIntPipe) id: number,
|
|
@Body() body: UpdateSupplierInput,
|
|
) {
|
|
return this.supplierService.update({ id }, body);
|
|
}
|
|
|
|
@Delete(":id")
|
|
remove(@Param("id", ParseIntPipe) id: number) {
|
|
return this.supplierService.delete({ id });
|
|
}
|
|
}
|