implmentação swagger no modulo orders-payment
This commit is contained in:
@@ -1,31 +1,59 @@
|
||||
/* eslint-disable prettier/prettier */
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
|
||||
/*
|
||||
https://docs.nestjs.com/controllers#controllers
|
||||
*/
|
||||
|
||||
import { Body, Controller, Get, Param, Post } from '@nestjs/common';
|
||||
import { Body, Controller, Get, Param, Post,UseGuards } from '@nestjs/common';
|
||||
import { ProductsService } from './products.service';
|
||||
import { ExposedProduct } from '../core/models/exposed-product.model';
|
||||
import { ExposedProduct } from 'src/core/models/exposed-product.model';
|
||||
import { JwtAuthGuard } from 'src/auth/guards/jwt-auth.guard';
|
||||
import { ExposedProductDto } from './dto/exposed-product.dto';
|
||||
import { ProductValidationDto } from './dto/ProductValidationDto';
|
||||
import { ProductEcommerceDto } from './dto/product-ecommerce.dto';
|
||||
import { ApiTags, ApiOperation, ApiParam, ApiBody, ApiResponse, ApiBearerAuth } from '@nestjs/swagger';
|
||||
|
||||
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiTags('Produtos')
|
||||
@Controller('api/v1/products')
|
||||
export class ProductsController {
|
||||
constructor(private readonly productsService: ProductsService) {}
|
||||
|
||||
constructor(private readonly productsService: ProductsService) { }
|
||||
///enpoit produtos-ecommecer
|
||||
@Get('products-ecommerce')
|
||||
@ApiOperation({ summary: 'Lista produtos para o e-commerce' })
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'Lista de produtos retornada com sucesso.',
|
||||
type: ProductEcommerceDto,
|
||||
isArray: true
|
||||
})
|
||||
|
||||
@Get('products-ecommerce')
|
||||
async productsEcommerce() {
|
||||
return this.productsService.getProductsEcommerce();
|
||||
}
|
||||
///ENDPOIT DE VALIDAR PRODUTO POR FILTRO
|
||||
@Get('product-validation/:storeId/:filtro')
|
||||
@ApiOperation({ summary: 'Valida produto pelo filtro (código, EAN ou descrição)' })
|
||||
@ApiParam({ name: 'storeId', type: String, description: 'ID da loja' })
|
||||
@ApiParam({ name: 'filtro', type: String, description: 'Filtro de busca (código, EAN ou descrição)' })
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'Produto encontrado com sucesso.',
|
||||
type: ProductValidationDto
|
||||
})
|
||||
@ApiResponse({ status: 404, description: 'Produto não localizado.' })
|
||||
async productValidation(
|
||||
@Param('storeId') storeId: string,
|
||||
@Param('filtro') filtro: string,
|
||||
): Promise<ProductValidationDto> {
|
||||
return this.productsService.productsValidation(storeId, filtro);
|
||||
}
|
||||
|
||||
@Get('product-validation/:storeId/:filtro')
|
||||
async productValidation(@Param('storeId') storeId: string, @Param('filtro') filtro: string) {
|
||||
return this.productsService.productsValidation(storeId, filtro);
|
||||
}
|
||||
|
||||
@Post('exposed-product')
|
||||
async exposedProduct(@Body() exposedProduct: ExposedProduct) {
|
||||
return this.productsService.exposedProduct(exposedProduct);
|
||||
}
|
||||
|
||||
/// ENDPOIT PRODUTOS EXPOSTOS
|
||||
@Post('exposed-product')
|
||||
@ApiOperation({ summary: 'Registra produto em exposição' })
|
||||
@ApiBody({ type: ExposedProductDto })
|
||||
@ApiResponse({ status: 201, description: 'Produto exposto registrado com sucesso.' })
|
||||
async exposedProduct(@Body() exposedProduct: ExposedProduct) {
|
||||
return this.productsService.exposedProduct(exposedProduct);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user