diff --git a/src/carrera-programa/carrera-programa.controller.ts b/src/carrera-programa/carrera-programa.controller.ts index 289b5ec..374c70f 100644 --- a/src/carrera-programa/carrera-programa.controller.ts +++ b/src/carrera-programa/carrera-programa.controller.ts @@ -2,7 +2,7 @@ import { Body, Controller, Delete, Get, Param, Post } from '@nestjs/common'; import { CarreraProgramaService } from './carrera-programa.service'; import { CarreraProgramaCreateDto } from './dto/carrera-programa-create.dto'; import { CarreraProgramaUpdateDto } from './dto/carrera-programa-update.dto'; -import {ApiTags} from '@nestjs/swagger' +import {ApiOperation, ApiTags} from '@nestjs/swagger' @Controller('carrera-programa') @ApiTags('carrera-programa') @@ -10,6 +10,9 @@ export class CarreraProgramaController { constructor(private carreraProgramaService: CarreraProgramaService) {} @Post() + @ApiOperation({ + description: 'Creamos una carrera programa, pasandole los parametros id_carrera y id_programa' + }) create(@Body() body: CarreraProgramaCreateDto) { return this.carreraProgramaService.create( body.id_carrera, @@ -18,11 +21,17 @@ export class CarreraProgramaController { } @Delete(':id') + @ApiOperation({ + description: 'Borramos una carrera programa a partir del id (id_carrera_programa)' + }) delete(@Param('id') id_carrera_programa: number) { return this.carreraProgramaService.delete(id_carrera_programa) } @Get() + @ApiOperation({ + description: 'Nos trae todas las carrera-programa' + }) get() { return this.carreraProgramaService.findAll(); } diff --git a/src/carrito/carrito.controller.ts b/src/carrito/carrito.controller.ts index 293848e..738b3e8 100644 --- a/src/carrito/carrito.controller.ts +++ b/src/carrito/carrito.controller.ts @@ -4,7 +4,7 @@ import { CarritoCreateDto } from './dto/carrito-create.dto'; import { CarritoUpdateDto } from './dto/carrito-update.dto'; import { CarritoGetDto } from './dto/carrito-get-dto'; import { CarritoDto } from './dto/carrito.dto' -import {ApiTags} from '@nestjs/swagger' +import {ApiOperation, ApiTags} from '@nestjs/swagger' @Controller('carrito') @ApiTags('carrito') @@ -12,6 +12,9 @@ export class CarritoController { constructor(private carritoService: CarritoService) {} @Post() + @ApiOperation({ + description: 'Creamos un carrito, pasandole los parametros id_tipo_carrito y id_modulo' + }) create(@Body() body: CarritoCreateDto) { return this.carritoService.create( body.id_tipo_carrito, @@ -20,16 +23,25 @@ export class CarritoController { } @Get() + @ApiOperation({ + description: 'Nos trae todos los carritos' + }) get() { return this.carritoService.findAll(); } @Get('carrito') + @ApiOperation({ + description: 'Nos trae un carrito en especifico, pasandole el parámetro id_carrito' + }) carrito(@Query() query: CarritoDto) { return this.carritoService.findById(parseInt(query.id_carrito)); } @Get('carritos') + @ApiOperation({ + description: 'Nos trae todos los carritos de un módulo, con el parámetro del id_modulo' + }) carritos(@Query() query: CarritoGetDto) { return this.carritoService.findByIdModulo(query); } @@ -38,6 +50,9 @@ export class CarritoController { carritosInstitucion() {} @Put() + @ApiOperation({ + description: 'Actualizamos información de un carrito' + }) update(@Body() body: CarritoUpdateDto) { return this.carritoService.update(body); } diff --git a/src/equipo/equipo.controller.ts b/src/equipo/equipo.controller.ts index d3dec0b..64205b6 100644 --- a/src/equipo/equipo.controller.ts +++ b/src/equipo/equipo.controller.ts @@ -1,7 +1,7 @@ import { Controller, Get, Post, Put, Query } from '@nestjs/common'; import { EquipoService } from './equipo.service'; import { EquipoDto } from './dto/equipo.dto'; -import { ApiTags } from '@nestjs/swagger'; +import { ApiOperation, ApiTags } from '@nestjs/swagger'; @Controller('equipo') @ApiTags('equipo') @@ -9,11 +9,17 @@ export class EquipoController { constructor(private equipoService: EquipoService) {} @Get() + @ApiOperation({ + description: 'Traemos todos los equipos', + }) get() { return this.equipoService.findAll(); } @Get('equipo') + @ApiOperation({ + description: 'Buscamos un equipo en base al id_equipo', + }) equipo(@Query() query: EquipoDto) { return this.equipoService.findById(parseInt(query.id_equipo)); } diff --git a/src/hora-excepcion/hora-excepcion.controller.ts b/src/hora-excepcion/hora-excepcion.controller.ts index 6b2d735..d8b44ca 100644 --- a/src/hora-excepcion/hora-excepcion.controller.ts +++ b/src/hora-excepcion/hora-excepcion.controller.ts @@ -1,7 +1,7 @@ import { Body, Controller, Delete, Get, Post, Param } from '@nestjs/common'; import { HoraExcepcionService } from './hora-excepcion.service'; import { HoraExcepcionDto } from './dto/hora-excepcion-create.dto'; -import { ApiTags } from '@nestjs/swagger'; +import { ApiOperation, ApiTags } from '@nestjs/swagger'; @Controller('hora-excepcion') @ApiTags('hora-excepcion') @@ -9,11 +9,18 @@ export class HoraExcepcionController { constructor(private horaExcepcionService: HoraExcepcionService) {} @Post() + @ApiOperation({ + description: 'Creamos una institucion-dia con el id_institucion_dia', + }) create(@Body() body: HoraExcepcionDto) { return this.horaExcepcionService.create(body.id_institucion_dia); } @Delete(':id') + @ApiOperation({ + description: + 'Con este delete borramos una hora_excepcion con ayuda de su id', + }) delete(@Param('id') id_hora_excepcion: number) { return this.horaExcepcionService.delete(id_hora_excepcion); } diff --git a/src/hora-excepcion/hora-excepcion.service.ts b/src/hora-excepcion/hora-excepcion.service.ts index 6d7114c..a3d557b 100644 --- a/src/hora-excepcion/hora-excepcion.service.ts +++ b/src/hora-excepcion/hora-excepcion.service.ts @@ -29,7 +29,7 @@ export class HoraExcepcionService { .findOne({ id_hora_excepcion }) .then((horaExcepcion) => { if (!horaExcepcion) - throw new NotFoundException('No existe esta carrera-programa'); + throw new NotFoundException('No existe la hora excepción'); return horaExcepcion; }); } diff --git a/src/upload-file/upload-file.service.ts b/src/upload-file/upload-file.service.ts index 85e0565..1576f63 100644 --- a/src/upload-file/upload-file.service.ts +++ b/src/upload-file/upload-file.service.ts @@ -26,12 +26,24 @@ export class UploadFileService { async createEquipos(file: Express.Multer.File, id_institucion: number) { const path = `${file.destination}/${file.filename}`; const institucion = await this.institucionService.findById(id_institucion); + const errores: string[] = []; if (!file) throw new BadRequestException('No se mando un archivo.'); csvtojson() .fromFile(path) .then(async (equipos) => { - for (let i = 0; i < equipos.length; i++) {} + for (let i = 0; i < equipos.length; i++) { + if(!equipos[i].modulo) errores.push(`${this.errorBase(i)} falta el campo modulo en el archivo`) + if(!equipos[i].carrito) errores.push(`${this.errorBase(i)} falta el campo carrito en el archivo`) + if(!equipos[i].tipo) errores.push(`${this.errorBase(i)} falta el campo tipo en el archivo`) + if(!equipos[i].equipo) errores.push(`${this.errorBase(i)} falta el campo equipo en el archivo`) + if(!equipos[i].numero_inventario) errores.push(`${this.errorBase(i)} falta el campo numero_inventario en el archivo`) + if(!equipos[i].numero_serie) errores.push(`${this.errorBase(i)} falta el campo numero_serie en el archivo`) + if(!equipos[i].modulo) errores.push(`${this.errorBase(i)} falta el campo modulo en el archivo`) + if(!equipos[i].entradas) errores.push(`${this.errorBase(i)} falta el campo entradas en el archivo`) + // faltan los programas + if(!equipos[i].programas) errores.push(`${this.errorBase(i)} falta el campo programas en el archivo`) + } }); }