100 lines
2.8 KiB
TypeScript
100 lines
2.8 KiB
TypeScript
import {
|
|
Body,
|
|
Controller,
|
|
Delete,
|
|
Get,
|
|
Post,
|
|
Put,
|
|
Query,
|
|
UseGuards,
|
|
} from '@nestjs/common';
|
|
import { AuthGuard } from '@nestjs/passport';
|
|
import { ApiBody, ApiOperation, ApiQuery, ApiTags } from '@nestjs/swagger';
|
|
import { Serealize } from '../interceptors/serialize.interceptor';
|
|
import { HoraExcepcionService } from './hora-excepcion.service';
|
|
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')
|
|
export class HoraExcepcionController {
|
|
constructor(private horaExcepcionService: HoraExcepcionService) {}
|
|
|
|
@Post()
|
|
// @UseGuards(AuthGuard('jwt'))
|
|
@ApiOperation({
|
|
description: 'Endpoint que crea una hora excepción.',
|
|
})
|
|
@ApiBody({
|
|
description: 'Todas las variables son obligatorias.',
|
|
examples: {
|
|
ejemplo: {
|
|
value: {
|
|
id_institucion_dia: 217,
|
|
hora_inicio: ':',
|
|
hora_fin: ':',
|
|
},
|
|
},
|
|
},
|
|
})
|
|
create(@Body() body: CreateHoraExcepcionDto) {
|
|
return this.horaExcepcionService.create(
|
|
body.id_institucion_dia,
|
|
body.hora_inicio,
|
|
body.hora_fin,
|
|
);
|
|
}
|
|
|
|
@Delete()
|
|
// @UseGuards(AuthGuard('jwt'))
|
|
@ApiOperation({
|
|
description: 'Endpoint que elimina una hora excepción.',
|
|
})
|
|
@ApiBody({
|
|
description: 'Es obligatorio mandar la variable id_hora_excepcion.',
|
|
examples: { ejemplo: { value: { id_hora_excepcion: 1 } } },
|
|
})
|
|
delete(@Body() body: DeleteHoraExcepcionDto) {
|
|
return this.horaExcepcionService.delete(body.id_hora_excepcion);
|
|
}
|
|
|
|
@Serealize(HoraExcepcionOutputDto)
|
|
@Get()
|
|
// @UseGuards(AuthGuard('jwt'))
|
|
@ApiOperation({
|
|
description:
|
|
'Endpoint que retorna las horas excepcion de un día de una institución.',
|
|
})
|
|
@ApiQuery({
|
|
description: 'Id de la institucion día',
|
|
name: 'id_institucion_dia',
|
|
})
|
|
get(@Query() query: GetHoraExcepcionDto) {
|
|
return this.horaExcepcionService.findAllByIdInstitucionDia(
|
|
parseInt(query.id_institucion_dia),
|
|
);
|
|
}
|
|
|
|
@Put()
|
|
// @UseGuards(AuthGuard('jwt'))
|
|
@ApiOperation({
|
|
description:
|
|
'Endpoint que actualiza lan información de una hora excepcion.',
|
|
})
|
|
@ApiBody({
|
|
description:
|
|
'Todoas las variables a excepción de id_hora_excepcion son opcionales pero se tiene que mandar forzosamente una hora.',
|
|
examples: {
|
|
ejemplo: {
|
|
value: { id_hora_excepcion: 1, _hora_fin: '', _hora_inicio: '' },
|
|
},
|
|
},
|
|
})
|
|
update(@Body() body: UpdateHoraExcepcionDto) {
|
|
return this.horaExcepcionService.update(body);
|
|
}
|
|
}
|