listo marcas
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import { Body, Controller, Get, Post, Query, UseGuards } from '@nestjs/common';
|
||||
import { AuthGuard } from '@nestjs/passport';
|
||||
import {
|
||||
ApiBearerAuth,
|
||||
ApiBody,
|
||||
ApiOperation,
|
||||
ApiQuery,
|
||||
ApiTags,
|
||||
} from '@nestjs/swagger';
|
||||
import { Serealize } from '../interceptors/serialize.interceptor';
|
||||
import { MarcaService } from './marca.service';
|
||||
import { CreateMarcaDto } from './dto/input/create.dto';
|
||||
import { MarcaDto } from './dto/input/marca.dto';
|
||||
import { MarcaOutputDto } from './dto/output/marca.dto';
|
||||
|
||||
@Controller('marca')
|
||||
@ApiTags('marca')
|
||||
export class MarcaController {
|
||||
constructor(private marcaService: MarcaService) {}
|
||||
|
||||
@Serealize(MarcaOutputDto)
|
||||
@Get()
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@ApiOperation({ description: 'Endpoint que retorna todass las marcas.' })
|
||||
@ApiBearerAuth('jwt')
|
||||
@ApiQuery({
|
||||
description: 'Tipo de marca que se busca.',
|
||||
name: 'tipo',
|
||||
type: 'text',
|
||||
})
|
||||
get(@Query() query: MarcaDto) {
|
||||
return this.marcaService.findAll(query.tipo);
|
||||
}
|
||||
|
||||
@Post()
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@ApiOperation({ description: 'Endpoint que crea una nueva marca.' })
|
||||
@ApiBearerAuth('jwt')
|
||||
@ApiBody({
|
||||
description: 'Todas las variables son obligatorias.',
|
||||
examples: { ejemplo: { value: { marca: '', tipo: '' } } },
|
||||
})
|
||||
create(@Body() body: CreateMarcaDto) {
|
||||
return this.marcaService.create(body.marca, body.tipo);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user