72 lines
2.9 KiB
TypeScript
72 lines
2.9 KiB
TypeScript
import { Controller, Get, Param, UseGuards } from '@nestjs/common';
|
|
import { ApiTags, ApiOperation, ApiParam, ApiBearerAuth, ApiResponse } from '@nestjs/swagger';
|
|
import { DataConsultService } from './data-consult.service';
|
|
import { JwtAuthGuard } from 'src/auth/guards/jwt-auth.guard'
|
|
import { ProductDto } from './dto/product.dto';
|
|
import { StoreDto } from './dto/store.dto';
|
|
import { SellerDto } from './dto/seller.dto';
|
|
import { BillingDto } from './dto/billing.dto';
|
|
import { CustomerDto } from './dto/customer.dto';
|
|
|
|
@ApiTags('DataConsult')
|
|
@Controller('api/v1/data-consult')
|
|
export class DataConsultController {
|
|
|
|
constructor(private readonly dataConsultService: DataConsultService) {}
|
|
|
|
@UseGuards(JwtAuthGuard)
|
|
@ApiBearerAuth()
|
|
@Get('stores')
|
|
@ApiOperation({ summary: 'Lista todas as lojas' })
|
|
@ApiResponse({ status: 200, description: 'Lista de lojas retornada com sucesso', type: [StoreDto] })
|
|
async stores(): Promise<StoreDto[]> {
|
|
return this.dataConsultService.stores();
|
|
}
|
|
|
|
@UseGuards(JwtAuthGuard)
|
|
@ApiBearerAuth()
|
|
@Get('sellers')
|
|
@ApiOperation({ summary: 'Lista todos os vendedores' })
|
|
@ApiResponse({ status: 200, description: 'Lista de vendedores retornada com sucesso', type: [SellerDto] })
|
|
async sellers(): Promise<SellerDto[]> {
|
|
return this.dataConsultService.sellers();
|
|
}
|
|
|
|
@UseGuards(JwtAuthGuard)
|
|
@ApiBearerAuth()
|
|
@Get('billings')
|
|
@ApiOperation({ summary: 'Retorna informações de faturamento' })
|
|
@ApiResponse({ status: 200, description: 'Informações de faturamento retornadas com sucesso', type: [BillingDto] })
|
|
async billings(): Promise<BillingDto[]> {
|
|
return this.dataConsultService.billings();
|
|
}
|
|
|
|
@UseGuards(JwtAuthGuard)
|
|
@ApiBearerAuth()
|
|
@Get('customers/:filter')
|
|
@ApiOperation({ summary: 'Filtra clientes pelo parâmetro fornecido' })
|
|
@ApiParam({ name: 'filter', description: 'Filtro de busca para clientes' })
|
|
@ApiResponse({ status: 200, description: 'Lista de clientes filtrados retornada com sucesso', type: [CustomerDto] })
|
|
async customer(@Param('filter') filter: string): Promise<CustomerDto[]> {
|
|
return this.dataConsultService.customers(filter);
|
|
}
|
|
|
|
@Get('products/:filter')
|
|
@ApiOperation({ summary: 'Busca produtos filtrados' })
|
|
@ApiParam({ name: 'filter', description: 'Filtro de busca' })
|
|
@ApiResponse({ status: 200, description: 'Lista de produtos filtrados retornada com sucesso', type: [ProductDto] })
|
|
async products(@Param('filter') filter: string): Promise<ProductDto[]> {
|
|
return this.dataConsultService.products(filter);
|
|
}
|
|
|
|
|
|
@Get('all')
|
|
@UseGuards(JwtAuthGuard)
|
|
@ApiBearerAuth()
|
|
@ApiOperation({ summary: 'VIEW DE 500 PRODUTOS' })
|
|
@ApiResponse({ status: 200, description: 'Lista de 500 produtos retornada com sucesso', type: [ProductDto] })
|
|
async getAllProducts(): Promise<ProductDto[]> {
|
|
return this.dataConsultService.getAllProducts();
|
|
}
|
|
|
|
} |