institucion-infraccion input output dto
This commit is contained in:
parent
e21fb2f6b1
commit
5f08c6d3f0
@ -1,6 +1,6 @@
|
|||||||
import { IsString } from 'class-validator';
|
import { IsString } from 'class-validator';
|
||||||
|
|
||||||
export class InstitucionInfraccionCreateDto {
|
export class CreateInstitucionInfraccionDto {
|
||||||
@IsString()
|
@IsString()
|
||||||
infraccion: string;
|
infraccion: string;
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
import { IsInt, IsNumber } from 'class-validator';
|
import { IsInt, IsNumber } from 'class-validator';
|
||||||
|
|
||||||
export class InstitucionInfraccionUpdateDto {
|
export class UpdateInstitucionInfraccionDto {
|
||||||
@IsInt()
|
@IsInt()
|
||||||
id_institucion_infraccion: number;
|
id_institucion_infraccion: number;
|
||||||
|
|
9
src/institucion-infraccion/dto/output/infraccion.dto.ts
Normal file
9
src/institucion-infraccion/dto/output/infraccion.dto.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import { Expose } from 'class-transformer';
|
||||||
|
|
||||||
|
export class InfraccionOutputDto {
|
||||||
|
@Expose()
|
||||||
|
id_infraccion;
|
||||||
|
|
||||||
|
@Expose()
|
||||||
|
infraccion;
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
import { Expose, Type } from 'class-transformer';
|
||||||
|
import { InfraccionOutputDto } from './infraccion.dto';
|
||||||
|
|
||||||
|
export class InstitucionInfraccionOutputDto {
|
||||||
|
@Expose()
|
||||||
|
id_institucion_infraccion;
|
||||||
|
|
||||||
|
@Expose()
|
||||||
|
dias_multa;
|
||||||
|
|
||||||
|
@Expose()
|
||||||
|
@Type(() => InfraccionOutputDto)
|
||||||
|
infraccion;
|
||||||
|
}
|
@ -1,10 +1,12 @@
|
|||||||
import { Body, Controller, Get, Post, Put, Query } from '@nestjs/common';
|
import { Body, Controller, Get, Post, Put, Query } from '@nestjs/common';
|
||||||
|
import { ApiBody, ApiOperation, ApiQuery, ApiTags } from '@nestjs/swagger';
|
||||||
|
import { Serealize } from '../interceptors/serialize.interceptor';
|
||||||
import { InstitucionInfraccionService } from './institucion-infraccion.service';
|
import { InstitucionInfraccionService } from './institucion-infraccion.service';
|
||||||
import { IdInstitucionDto } from '../dto/id-institucion.dto';
|
import { IdInstitucionDto } from '../dto/id-institucion.dto';
|
||||||
import { InstitucionInfraccionCreateDto } from './dto/institucion-infraccion-create.dto';
|
import { CreateInstitucionInfraccionDto } from './dto/input/create.dto';
|
||||||
import { InstitucionInfraccionUpdateDto } from './dto/institucion-infraccion-update.dto';
|
import { UpdateInstitucionInfraccionDto } from './dto/input/update.dto';
|
||||||
import { ApiBody, ApiOperation, ApiQuery, ApiTags } from '@nestjs/swagger';
|
import { InfraccionOutputDto } from './dto/output/infraccion.dto';
|
||||||
import e from 'express';
|
import { InstitucionInfraccionOutputDto } from './dto/output/institucion-infraccion.dto';
|
||||||
|
|
||||||
@Controller('institucion-infraccion')
|
@Controller('institucion-infraccion')
|
||||||
@ApiTags('institucion-infraccion')
|
@ApiTags('institucion-infraccion')
|
||||||
@ -19,16 +21,18 @@ export class InstitucionInfraccionController {
|
|||||||
description: 'Es obligatorio mandar la variable infraccion.',
|
description: 'Es obligatorio mandar la variable infraccion.',
|
||||||
examples: { ejemplo: { value: { infraccion: '' } } },
|
examples: { ejemplo: { value: { infraccion: '' } } },
|
||||||
})
|
})
|
||||||
create(@Body() body: InstitucionInfraccionCreateDto) {
|
create(@Body() body: CreateInstitucionInfraccionDto) {
|
||||||
return this.institucionInfraccionService.create(body.infraccion);
|
return this.institucionInfraccionService.create(body.infraccion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Serealize(InfraccionOutputDto)
|
||||||
@Get()
|
@Get()
|
||||||
@ApiOperation({ description: 'Endpoint que retorna todas las infracciones.' })
|
@ApiOperation({ description: 'Endpoint que retorna todas las infracciones.' })
|
||||||
get() {
|
get() {
|
||||||
return this.institucionInfraccionService.findAll();
|
return this.institucionInfraccionService.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Serealize(InstitucionInfraccionOutputDto)
|
||||||
@Get('infracciones')
|
@Get('infracciones')
|
||||||
@ApiOperation({
|
@ApiOperation({
|
||||||
description: 'Endpoint que retorna las infracciones de una institución.',
|
description: 'Endpoint que retorna las infracciones de una institución.',
|
||||||
@ -54,7 +58,7 @@ export class InstitucionInfraccionController {
|
|||||||
ejemplo: { value: { id_institucion_infraccion: 603, dias_multa: 7 } },
|
ejemplo: { value: { id_institucion_infraccion: 603, dias_multa: 7 } },
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
update(@Body() body: InstitucionInfraccionUpdateDto) {
|
update(@Body() body: UpdateInstitucionInfraccionDto) {
|
||||||
return this.institucionInfraccionService.update(body);
|
return this.institucionInfraccionService.update(body);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user