From 5eb2fef2f1bf04fd7b031865f41d7ee17b8b780e Mon Sep 17 00:00:00 2001 From: xXpuma99Xx <51341582+xXpuma99Xx@users.noreply.github.com> Date: Mon, 27 Jun 2022 18:50:01 -0500 Subject: [PATCH] =?UTF-8?q?dga=20y=20dgp=20a=20espera=20de=20soap=20conexi?= =?UTF-8?q?=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/18-todo.sql | 1 - .../institucion-usuario.service.ts | 6 +- src/upload-file/upload-file.service.ts | 2 +- src/usuario/dto/input/dgp.dto.ts | 3 + src/usuario/dto/output/escolares.dto.ts | 14 ++--- src/usuario/usuario.controller.ts | 6 +- src/usuario/usuario.service.ts | 56 +++++++++---------- upload/plantilla_alumnos.csv | 7 ++- 8 files changed, 49 insertions(+), 46 deletions(-) diff --git a/sql/18-todo.sql b/sql/18-todo.sql index 6e79b77..bad66eb 100644 --- a/sql/18-todo.sql +++ b/sql/18-todo.sql @@ -1836,7 +1836,6 @@ INSERT INTO institucion_dia(id_institucion, id_dia) VALUES(1, 2); INSERT INTO institucion_dia(id_institucion, id_dia) VALUES(1, 3); INSERT INTO institucion_dia(id_institucion, id_dia) VALUES(1, 4); INSERT INTO institucion_dia(id_institucion, id_dia) VALUES(1, 5); -INSERT INTO institucion_dia(id_institucion, id_dia) VALUES(1, 5); INSERT INTO institucion_dia(id_institucion, id_dia) VALUES(2, 1); INSERT INTO institucion_dia(id_institucion, id_dia) VALUES(2, 2); INSERT INTO institucion_dia(id_institucion, id_dia) VALUES(2, 3); diff --git a/src/institucion-usuario/institucion-usuario.service.ts b/src/institucion-usuario/institucion-usuario.service.ts index a385df6..2c126a4 100644 --- a/src/institucion-usuario/institucion-usuario.service.ts +++ b/src/institucion-usuario/institucion-usuario.service.ts @@ -37,7 +37,11 @@ export class InstitucionUsuarioService { campo: string, ) { return this.repository - .findOne({ usuario, institucionCarrera }) + .findOne({ + activo: true, + institucionCarrera, + usuario, + }) .then((institucionUsuario) => { if (!institucionUsuario) throw new ConflictException( diff --git a/src/upload-file/upload-file.service.ts b/src/upload-file/upload-file.service.ts index b181488..bf28efa 100644 --- a/src/upload-file/upload-file.service.ts +++ b/src/upload-file/upload-file.service.ts @@ -298,7 +298,7 @@ export class UploadFileService { (carrera && !institucionCarrera) ) { if (!tipoUsuario) error += ' no existe este tipo de usuario.'; - if (tipoUsuario.id_tipo_usuario < 5) + else if (tipoUsuario.id_tipo_usuario < 5) ' no se puede asignar este tipo de usuario a este usuario.'; if (!carrera) error += ' falta del campo carrera para el alumno.'; if (carrera && !institucionCarrera) diff --git a/src/usuario/dto/input/dgp.dto.ts b/src/usuario/dto/input/dgp.dto.ts index 26c77ea..be87c24 100644 --- a/src/usuario/dto/input/dgp.dto.ts +++ b/src/usuario/dto/input/dgp.dto.ts @@ -1,6 +1,9 @@ import { IsString } from 'class-validator'; export class DgpInputDto { + @IsString() + id_institucion: string; + @IsString() rfc: string; diff --git a/src/usuario/dto/output/escolares.dto.ts b/src/usuario/dto/output/escolares.dto.ts index d0fb2c5..313d89c 100644 --- a/src/usuario/dto/output/escolares.dto.ts +++ b/src/usuario/dto/output/escolares.dto.ts @@ -1,22 +1,16 @@ import { Expose, Type } from 'class-transformer'; import { InstitucionCarreaOutputDto } from '../../../institucion-carrera/dto/output/institucion-carrera.dto'; -import { TipoUsuarioOutputDto } from '../../../tipo-usuario/dto/output/tipo-usuario.dto'; +import { UsuariosOutputDto } from './usuarios.dto'; export class EscolaresOutputDto { @Expose() - id_usuario; - - @Expose() - nombre; - - @Expose() - usuario; + id_institucion_usuario; @Expose() @Type(() => InstitucionCarreaOutputDto) institucionCarrera; @Expose() - @Type(() => TipoUsuarioOutputDto) - tipoUsuario; + @Type(() => UsuariosOutputDto) + usuario; } diff --git a/src/usuario/usuario.controller.ts b/src/usuario/usuario.controller.ts index 15015c8..edc9e4c 100644 --- a/src/usuario/usuario.controller.ts +++ b/src/usuario/usuario.controller.ts @@ -60,7 +60,11 @@ export class UsuarioController { }) @ApiQuery({ description: 'RFC del profesor.', name: 'rfc', type: 'string' }) dgp(@Query() query: DgpInputDto) { - return this.usuarioService.DGP(query.usuario, query.rfc); + return this.usuarioService.DGP( + parseInt(query.id_institucion), + query.usuario, + query.rfc, + ); } @Post('registrar') diff --git a/src/usuario/usuario.service.ts b/src/usuario/usuario.service.ts index 6b3192f..bda5d34 100644 --- a/src/usuario/usuario.service.ts +++ b/src/usuario/usuario.service.ts @@ -75,39 +75,37 @@ export class UsuarioService { id_institucion_carrera, ); - return this.findByUsuario(usuario, true, true).then( - async (existeUsuario) => { - /* Falta conexión a soap */ - if (existeUsuario.password) - throw new ConflictException( - 'Ya fue regisrado este número de cuenta.', - ); - return this.institucionUsuarioService.findByUsuarioIdInstitucionCarrera( - existeUsuario, - institucionCarrera, - 'cuenta', - ); - }, - ); + return this.findByUsuario(usuario, true).then(async (existeUsuario) => { + /* Falta conexión a soap */ + if (existeUsuario.password) + throw new ConflictException('Ya fue regisrado este número de cuenta.'); + return this.institucionUsuarioService.findByUsuarioIdInstitucionCarrera( + existeUsuario, + institucionCarrera, + 'cuenta', + ); + }); } - async DGP(usuario: string, rfc: string) { - const institucionCarrera = await this.institucionCarreraService.findById(1); + async DGP(id_institucion: number, usuario: string, rfc: string) { + const institucionCarrera = + await this.institucionCarreraService.findByIdInstitucionIdCarrera( + id_institucion, + 1, + ); - return this.findByUsuario(usuario, true, true).then( - async (existeUsuario) => { - /* Falta conexión a soap */ - if (existeUsuario.password) - throw new ConflictException( - 'Ya fue regisrado este número de trabajador.', - ); - return this.institucionUsuarioService.findByUsuarioIdInstitucionCarrera( - existeUsuario, - institucionCarrera, - 'trabajador', + return this.findByUsuario(usuario, true).then(async (existeUsuario) => { + /* Falta conexión a soap */ + if (existeUsuario.password) + throw new ConflictException( + 'Ya fue regisrado este número de trabajador.', ); - }, - ); + return this.institucionUsuarioService.findByUsuarioIdInstitucionCarrera( + existeUsuario, + institucionCarrera, + 'trabajador', + ); + }); } async findAll(filtros: { diff --git a/upload/plantilla_alumnos.csv b/upload/plantilla_alumnos.csv index b19691b..1711879 100644 --- a/upload/plantilla_alumnos.csv +++ b/upload/plantilla_alumnos.csv @@ -1,4 +1,5 @@ numero_cuenta,nombres,apellido_p,apellido_m,carrera,tipo_usuario -313144567,Nombre 1,Apellido_p 1,Apellido_m 1,MATEMATICAS APLICADAS Y COMPUTACION,Alumno -415895839,Nombre 2,Apellido_p 2,Apellido_m 2,MEDICINA VETERINARIA Y ZOOTECNIA,Posgrado -813573,Nombre 3,Apellido_p 3,Apellido_m 3,,Profesor \ No newline at end of file +316313528,MARQUEZ,ROSAS,LEMUEL HELON,MATEMATICAS APLICADAS Y COMPUTACION,Alumno +316019251,ROMERO,VAZQUEZ,MARCO ANTONIO,ACTUARIA,Alumno +316304326,CARRERA,SERRANO,JEREMY,ARQUITECTURA,Alumno +419085500,SAAVEDRA,TREJO,ANDRES HERNAN,,Profesor