From a60c81726529e2e2f16a2d93bcc1383ea1e81fa5 Mon Sep 17 00:00:00 2001 From: Andres2908 Date: Mon, 2 May 2022 23:05:50 -0500 Subject: [PATCH 1/6] inicio de la carga masiva de equipos --- src/upload-file/upload-file.service.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/upload-file/upload-file.service.ts b/src/upload-file/upload-file.service.ts index 0cb3b18..7d26135 100644 --- a/src/upload-file/upload-file.service.ts +++ b/src/upload-file/upload-file.service.ts @@ -24,12 +24,25 @@ 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`) + + } }); } From e53e55a6b6301c4e9cf88c82bd14841efdb15d40 Mon Sep 17 00:00:00 2001 From: Andres2908 Date: Mon, 2 May 2022 23:17:26 -0500 Subject: [PATCH 2/6] =?UTF-8?q?decorador=20@ApiOperation,=20con=20la=20des?= =?UTF-8?q?cripci=C3=B3n=20del=20endpoint(carrito)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/carrito/carrito.controller.ts | 17 ++++++++++++++++- src/upload-file/upload-file.service.ts | 1 - 2 files changed, 16 insertions(+), 2 deletions(-) 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/upload-file/upload-file.service.ts b/src/upload-file/upload-file.service.ts index 7d26135..40e6f6b 100644 --- a/src/upload-file/upload-file.service.ts +++ b/src/upload-file/upload-file.service.ts @@ -41,7 +41,6 @@ export class UploadFileService { 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`) - } }); } From 3f83687b1c703985adb7daf5accb2535fae679c6 Mon Sep 17 00:00:00 2001 From: Andres2908 Date: Wed, 4 May 2022 09:38:48 -0500 Subject: [PATCH 3/6] carrera-programa ApiOperation --- src/carrera-programa/carrera-programa.controller.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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(); } From f5ca574f445fad3694ba26b61dea75cfd3c7895e Mon Sep 17 00:00:00 2001 From: Andres2908 Date: Wed, 4 May 2022 09:45:35 -0500 Subject: [PATCH 4/6] equipo ApiOperation --- src/equipo/equipo.controller.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/equipo/equipo.controller.ts b/src/equipo/equipo.controller.ts index a7c8904..d6f773f 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') @@ -13,11 +13,17 @@ export class EquipoController { cargaMasiva() {} @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)); } From 41f9dbb0e66225a4f11e28004ae4a698f1bb8063 Mon Sep 17 00:00:00 2001 From: Andres2908 Date: Wed, 4 May 2022 09:52:10 -0500 Subject: [PATCH 5/6] ApiOperation hora-exception --- src/hora-excepcion/hora-excepcion.controller.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/hora-excepcion/hora-excepcion.controller.ts b/src/hora-excepcion/hora-excepcion.controller.ts index 63f9487..06084b8 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, Put, 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,17 @@ 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) } From 2d5a0f4f473e535b98fa16aede22ff707e670e97 Mon Sep 17 00:00:00 2001 From: Andres2908 Date: Wed, 11 May 2022 21:54:56 -0500 Subject: [PATCH 6/6] hora excepcion --- src/hora-excepcion/hora-excepcion.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; }); }