implmentação swagger no modulo orders-payment
This commit is contained in:
@@ -1,40 +1,74 @@
|
||||
/* 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 { ApiTags, ApiOperation, ApiParam, ApiResponse } from '@nestjs/swagger';
|
||||
import { OrdersPaymentService } from './orders-payment.service';
|
||||
import { OrderDto } from './dto/order.dto';
|
||||
import { PaymentDto } from './dto/payment.dto';
|
||||
import { CreatePaymentDto } from './dto/create-payment.dto';
|
||||
import { CreateInvoiceDto } from './dto/create-invoice.dto';
|
||||
|
||||
@ApiTags('Orders Payment')
|
||||
@Controller('api/v1/orders-payment')
|
||||
export class OrdersPaymentController {
|
||||
|
||||
constructor(private readonly orderPaymentService: OrdersPaymentService){}
|
||||
|
||||
@Get('orders/:id')
|
||||
findOrders(@Param('id') storeId: string) {
|
||||
@ApiOperation({ summary: 'Lista todos os pedidos de uma loja' })
|
||||
@ApiParam({ name: 'id', description: 'ID da loja' })
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'Lista de pedidos retornada com sucesso',
|
||||
type: [OrderDto]
|
||||
})
|
||||
async findOrders(@Param('id') storeId: string): Promise<OrderDto[]> {
|
||||
return this.orderPaymentService.findOrders(storeId, 0);
|
||||
}
|
||||
|
||||
@Get('orders/:id/:orderId')
|
||||
findOrder(@Param('id') storeId: string,
|
||||
@Param('orderId') orderId: number) {
|
||||
return this.orderPaymentService.findOrders(storeId, orderId);
|
||||
@ApiOperation({ summary: 'Busca um pedido específico' })
|
||||
@ApiParam({ name: 'id', description: 'ID da loja' })
|
||||
@ApiParam({ name: 'orderId', description: 'ID do pedido' })
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'Pedido retornado com sucesso',
|
||||
type: OrderDto
|
||||
})
|
||||
async findOrder(
|
||||
@Param('id') storeId: string,
|
||||
@Param('orderId') orderId: number,
|
||||
): Promise<OrderDto> {
|
||||
const orders = await this.orderPaymentService.findOrders(storeId, orderId);
|
||||
return orders[0];
|
||||
}
|
||||
|
||||
@Get('payments/:id')
|
||||
findPayments(@Param('id') orderId: number) {
|
||||
@ApiOperation({ summary: 'Lista todos os pagamentos de um pedido' })
|
||||
@ApiParam({ name: 'id', description: 'ID do pedido' })
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'Lista de pagamentos retornada com sucesso',
|
||||
type: [PaymentDto]
|
||||
})
|
||||
async findPayments(@Param('id') orderId: number): Promise<PaymentDto[]> {
|
||||
return this.orderPaymentService.findPayments(orderId);
|
||||
}
|
||||
@Post('payments/create')
|
||||
createPayment(@Body() data: any) {
|
||||
@ApiOperation({ summary: 'Cria um novo pagamento' })
|
||||
@ApiResponse({
|
||||
status: 201,
|
||||
description: 'Pagamento criado com sucesso'
|
||||
})
|
||||
async createPayment(@Body() data: CreatePaymentDto): Promise<void> {
|
||||
return this.orderPaymentService.createPayment(data);
|
||||
}
|
||||
|
||||
@Post('invoice/create')
|
||||
createInvoice(@Body() data: any) {
|
||||
@ApiOperation({ summary: 'Cria uma nova fatura' })
|
||||
@ApiResponse({
|
||||
status: 201,
|
||||
description: 'Fatura criada com sucesso'
|
||||
})
|
||||
async createInvoice(@Body() data: CreateInvoiceDto): Promise<void> {
|
||||
return this.orderPaymentService.createInvoice(data);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user