hora-excepcion input output dto
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { IsInt, IsMilitaryTime } from 'class-validator';
|
||||
|
||||
export class HoraExcepcionCreateDto {
|
||||
export class CreateHoraExcepcionDto {
|
||||
@IsInt()
|
||||
id_institucion_dia: number;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { IsInt } from 'class-validator';
|
||||
|
||||
export class HoraExcepcionDeleteDto {
|
||||
export class DeleteHoraExcepcionDto {
|
||||
@IsInt()
|
||||
id_hora_excepcion: number;
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { IsNumberString } from 'class-validator';
|
||||
|
||||
export class HoraExcepcionGetDto {
|
||||
export class GetHoraExcepcionDto {
|
||||
@IsNumberString()
|
||||
id_institucion_dia: string;
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { IsInt, IsMilitaryTime, IsOptional } from 'class-validator';
|
||||
|
||||
export class HoraExcepcionUpdateDto {
|
||||
export class UpdateHoraExcepcionDto {
|
||||
@IsInt()
|
||||
id_hora_excepcion: number;
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Expose } from 'class-transformer';
|
||||
|
||||
export class HoraExcepcionOutputDto {
|
||||
@Expose()
|
||||
id_hora_excepcion;
|
||||
|
||||
@Expose()
|
||||
hora_fin;
|
||||
|
||||
@Expose()
|
||||
hora_inicio;
|
||||
}
|
||||
@@ -21,7 +21,6 @@ export class HoraExcepcion {
|
||||
@ManyToOne(
|
||||
() => InstitucionDia,
|
||||
(institucionDia) => institucionDia.horasExcepcion,
|
||||
{ eager: true },
|
||||
)
|
||||
@JoinColumn({ name: 'id_institucion_dia' })
|
||||
institucionDia: InstitucionDia;
|
||||
|
||||
@@ -8,11 +8,13 @@ import {
|
||||
Query,
|
||||
} from '@nestjs/common';
|
||||
import { ApiBody, ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||
import { Serealize } from '../interceptors/serialize.interceptor';
|
||||
import { HoraExcepcionService } from './hora-excepcion.service';
|
||||
import { HoraExcepcionCreateDto } from './dto/hora-excepcion-create.dto';
|
||||
import { HoraExcepcionDeleteDto } from './dto/hora-excepcion-delete.dto';
|
||||
import { HoraExcepcionGetDto } from './dto/hora-excepcion-get.dto';
|
||||
import { HoraExcepcionUpdateDto } from './dto/hora-excepcion-update.dto';
|
||||
import { CreateHoraExcepcionDto } from './dto/input/create.dto';
|
||||
import { DeleteHoraExcepcionDto } from './dto/input/delete.dto';
|
||||
import { GetHoraExcepcionDto } from './dto/input/get.dto';
|
||||
import { UpdateHoraExcepcionDto } from './dto/input/update.dto';
|
||||
import { HoraExcepcionOutputDto } from './dto/output/hora-excepcion.dto';
|
||||
|
||||
@Controller('hora-excepcion')
|
||||
@ApiTags('hora-excepcion')
|
||||
@@ -35,7 +37,7 @@ export class HoraExcepcionController {
|
||||
},
|
||||
},
|
||||
})
|
||||
create(@Body() body: HoraExcepcionCreateDto) {
|
||||
create(@Body() body: CreateHoraExcepcionDto) {
|
||||
return this.horaExcepcionService.create(
|
||||
body.id_institucion_dia,
|
||||
body.hora_inicio,
|
||||
@@ -51,16 +53,17 @@ export class HoraExcepcionController {
|
||||
description: 'Es obligatorio mandar la variable id_hora_excepcion.',
|
||||
examples: { ejemplo: { value: { id_hora_excepcion: 1 } } },
|
||||
})
|
||||
delete(@Body() body: HoraExcepcionDeleteDto) {
|
||||
delete(@Body() body: DeleteHoraExcepcionDto) {
|
||||
return this.horaExcepcionService.delete(body.id_hora_excepcion);
|
||||
}
|
||||
|
||||
@Serealize(HoraExcepcionOutputDto)
|
||||
@Get()
|
||||
@ApiOperation({
|
||||
description:
|
||||
'Endpoint que retorna las horas excepcion de un día de una institución.',
|
||||
})
|
||||
get(@Query() query: HoraExcepcionGetDto) {
|
||||
get(@Query() query: GetHoraExcepcionDto) {
|
||||
return this.horaExcepcionService.findAllByIdInstitucionDia(
|
||||
parseInt(query.id_institucion_dia),
|
||||
);
|
||||
@@ -80,7 +83,7 @@ export class HoraExcepcionController {
|
||||
},
|
||||
},
|
||||
})
|
||||
update(@Body() body: HoraExcepcionUpdateDto) {
|
||||
update(@Body() body: UpdateHoraExcepcionDto) {
|
||||
return this.horaExcepcionService.update(body);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user