- extend Prisma schema with products, product constructs and link tables\n- introduce product service, DTOs and includes with constructeur support\n- integrate product selections across model type skeletons, composants, pièces and machines\n- validate product requirements when building machine skeletons and payloads
44 lines
1.0 KiB
TypeScript
44 lines
1.0 KiB
TypeScript
import {
|
|
Body,
|
|
Controller,
|
|
Delete,
|
|
Get,
|
|
Param,
|
|
Patch,
|
|
Post,
|
|
Query,
|
|
} from '@nestjs/common';
|
|
import { ProductsService } from './products.service';
|
|
import { CreateProductDto, UpdateProductDto } from '../shared/dto/product.dto';
|
|
import { ListProductsQueryDto } from './dto/list-products.dto';
|
|
|
|
@Controller('products')
|
|
export class ProductsController {
|
|
constructor(private readonly productsService: ProductsService) {}
|
|
|
|
@Get()
|
|
list(@Query() query: ListProductsQueryDto) {
|
|
return this.productsService.list(query);
|
|
}
|
|
|
|
@Get(':id')
|
|
findOne(@Param('id') id: string) {
|
|
return this.productsService.findOne(id);
|
|
}
|
|
|
|
@Post()
|
|
create(@Body() createProductDto: CreateProductDto) {
|
|
return this.productsService.create(createProductDto);
|
|
}
|
|
|
|
@Patch(':id')
|
|
update(@Param('id') id: string, @Body() updateProductDto: UpdateProductDto) {
|
|
return this.productsService.update(id, updateProductDto);
|
|
}
|
|
|
|
@Delete(':id')
|
|
remove(@Param('id') id: string) {
|
|
return this.productsService.remove(id);
|
|
}
|
|
}
|