|
|
@ -6,15 +6,18 @@ import { |
|
|
|
Patch, |
|
|
|
Patch, |
|
|
|
Param, |
|
|
|
Param, |
|
|
|
Delete, |
|
|
|
Delete, |
|
|
|
|
|
|
|
UseGuards, |
|
|
|
} from '@nestjs/common'; |
|
|
|
} from '@nestjs/common'; |
|
|
|
import { ProductsService } from './products.service'; |
|
|
|
import { ProductsService } from './products.service'; |
|
|
|
import { CreateProductDto, UpdateProductDto } from './dto'; |
|
|
|
import { CreateProductDto, UpdateProductDto } from './dto'; |
|
|
|
import { UUID } from 'crypto'; |
|
|
|
import { UUID } from 'crypto'; |
|
|
|
|
|
|
|
import { AuthGuard } from '@nestjs/passport'; |
|
|
|
|
|
|
|
|
|
|
|
@Controller('products') |
|
|
|
@Controller('products') |
|
|
|
export class ProductsController { |
|
|
|
export class ProductsController { |
|
|
|
constructor(private readonly productsService: ProductsService) {} |
|
|
|
constructor(private readonly productsService: ProductsService) {} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@UseGuards(AuthGuard('jwt')) |
|
|
|
@Post() |
|
|
|
@Post() |
|
|
|
create(@Body() createProductDto: CreateProductDto) { |
|
|
|
create(@Body() createProductDto: CreateProductDto) { |
|
|
|
return this.productsService.create(createProductDto); |
|
|
|
return this.productsService.create(createProductDto); |
|
|
@ -30,11 +33,13 @@ export class ProductsController { |
|
|
|
return this.productsService.findOne(+id); |
|
|
|
return this.productsService.findOne(+id); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@UseGuards(AuthGuard('jwt')) |
|
|
|
@Patch(':id') |
|
|
|
@Patch(':id') |
|
|
|
update(@Param('id') id: string, @Body() updateProductDto: UpdateProductDto) { |
|
|
|
update(@Param('id') id: string, @Body() updateProductDto: UpdateProductDto) { |
|
|
|
return this.productsService.update(+id, updateProductDto); |
|
|
|
return this.productsService.update(+id, updateProductDto); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@UseGuards(AuthGuard('jwt')) |
|
|
|
@Delete(':id') |
|
|
|
@Delete(':id') |
|
|
|
remove(@Param('id') id: string) { |
|
|
|
remove(@Param('id') id: string) { |
|
|
|
return this.productsService.remove(+id); |
|
|
|
return this.productsService.remove(+id); |
|
|
|