|
|
|
@ -1,4 +1,4 @@ |
|
|
|
|
import { Controller, Get, Post, Body, Patch, Param, Delete, Res, Query } from "@nestjs/common"; |
|
|
|
|
import { Controller, Get, Post, Body, Param, Delete, Query, Put } from "@nestjs/common"; |
|
|
|
|
import { ProductsService } from "./products.service"; |
|
|
|
|
import { Product } from "./entities/product.entity"; |
|
|
|
|
|
|
|
|
@ -19,5 +19,17 @@ export class ProductsController { |
|
|
|
|
const { search, priceMin, priceMax } = query; |
|
|
|
|
return this.productsService.findAll(search, priceMin, priceMax); |
|
|
|
|
} |
|
|
|
|
@Get(':id') |
|
|
|
|
async findOne(@Param('id') id: string): Promise<Product> { |
|
|
|
|
return this.productsService.findOne(id); |
|
|
|
|
} |
|
|
|
|
@Put(':id') |
|
|
|
|
async update( |
|
|
|
|
@Param('id') id: string, |
|
|
|
|
@Body() body: { name?: string; description?: string; price?: number }, |
|
|
|
|
): Promise<Product> { |
|
|
|
|
const { name, description, price } = body; |
|
|
|
|
return this.productsService.update(id, name, description, price); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|