listo marcas
This commit is contained in:
@@ -1,10 +1,17 @@
|
||||
import { Body, Controller, Get, Post, UseGuards } from '@nestjs/common';
|
||||
import { Body, Controller, Get, Post, Query, UseGuards } from '@nestjs/common';
|
||||
import { AuthGuard } from '@nestjs/passport';
|
||||
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||
import {
|
||||
ApiBearerAuth,
|
||||
ApiBody,
|
||||
ApiOperation,
|
||||
ApiQuery,
|
||||
ApiTags,
|
||||
} from '@nestjs/swagger';
|
||||
import { Serealize } from '../interceptors/serialize.interceptor';
|
||||
import { ModeloService } from './modelo.service';
|
||||
import { ModeloOutputDto } from './dto/output/modelo.dto';
|
||||
import { CreateModeloDto } from './dto/input/create.dto';
|
||||
import { ModeloDto } from './dto/input/modelo.dto';
|
||||
import { ModeloOutputDto } from './dto/output/modelo.dto';
|
||||
|
||||
@Controller('modelo')
|
||||
@ApiTags('modelo')
|
||||
@@ -16,15 +23,24 @@ export class ModeloController {
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@ApiOperation({ description: 'Endpoint que retorna todos los modelos.' })
|
||||
@ApiBearerAuth('jwt')
|
||||
get() {
|
||||
return this.modeloService.findAll();
|
||||
@ApiQuery({
|
||||
description: 'Tipo de marca que se busca.',
|
||||
name: 'tipo',
|
||||
type: 'text',
|
||||
})
|
||||
get(@Query() query: ModeloDto) {
|
||||
return this.modeloService.findAll(query.tipo);
|
||||
}
|
||||
|
||||
@Post()
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@ApiOperation({ description: 'Endpoint que crea un nuevo modelo.' })
|
||||
@ApiBearerAuth('jwt')
|
||||
@ApiBody({
|
||||
description: 'Todas las variables son obligatorias.',
|
||||
examples: { ejemplo: { value: { modelo: '', tipo: '' } } },
|
||||
})
|
||||
create(@Body() body: CreateModeloDto) {
|
||||
return this.modeloService.create(body.modelo);
|
||||
return this.modeloService.create(body.modelo, body.tipo);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user