From ac709f96256d5aebbc4c473d75cd0cfe2092e5d9 Mon Sep 17 00:00:00 2001 From: xXpuma99Xx <51341582+xXpuma99Xx@users.noreply.github.com> Date: Mon, 13 Jun 2022 12:59:15 -0500 Subject: [PATCH] usuario input output --- sql/04-carrera.sql | 2 +- sql/18-todo.sql | 2 +- .../dto/output/institucion-carrera.dto.ts | 4 +-- .../dto/output/institucion-min.dto.ts | 9 +++++ .../dto/output/instituciones.dto.ts | 6 ++++ .../dgae.dto.ts} | 0 .../{usuario-dgp.dto.ts => input/dgp.dto.ts} | 0 .../registrar.dto.ts} | 0 .../update.dto.ts} | 0 src/usuario/dto/{ => input}/usuario.dto.ts | 0 .../usuarios.dto.ts} | 0 src/usuario/dto/output/escolares.dto.ts | 22 ++++++++++++ src/usuario/dto/output/usuario.dto.ts | 34 +++++++++++++++++++ src/usuario/dto/output/usuarios.dto.ts | 22 ++++++++++++ src/usuario/usuario.controller.ts | 20 +++++++---- 15 files changed, 111 insertions(+), 10 deletions(-) create mode 100644 src/institucion/dto/output/institucion-min.dto.ts rename src/usuario/dto/{usuario-dgae.dto.ts => input/dgae.dto.ts} (100%) rename src/usuario/dto/{usuario-dgp.dto.ts => input/dgp.dto.ts} (100%) rename src/usuario/dto/{usuario-registrar.dto.ts => input/registrar.dto.ts} (100%) rename src/usuario/dto/{usuario-update.dto.ts => input/update.dto.ts} (100%) rename src/usuario/dto/{ => input}/usuario.dto.ts (100%) rename src/usuario/dto/{usuario-usuarios.dto.ts => input/usuarios.dto.ts} (100%) create mode 100644 src/usuario/dto/output/escolares.dto.ts create mode 100644 src/usuario/dto/output/usuario.dto.ts create mode 100644 src/usuario/dto/output/usuarios.dto.ts diff --git a/sql/04-carrera.sql b/sql/04-carrera.sql index 7737f09..34a92d2 100644 --- a/sql/04-carrera.sql +++ b/sql/04-carrera.sql @@ -1,4 +1,4 @@ -INSERT INTO carrera(id_carrera, carrera, clave) VALUES (1, 'PROFESOR', '1', 8); +INSERT INTO carrera(id_carrera, carrera, clave, id_nivel) VALUES (1, 'PROFESOR', '1', 8); INSERT INTO carrera(id_carrera, carrera, clave, id_nivel) VALUES (101, 'ACTUARIA', '101', 4); INSERT INTO carrera(id_carrera, carrera, clave, id_nivel) VALUES (102, 'ARQUITECTURA', '102', 4); INSERT INTO carrera(id_carrera, carrera, clave, id_nivel) VALUES (103, 'ARQUITECTURA DEL PAISAJE', '103', 4); diff --git a/sql/18-todo.sql b/sql/18-todo.sql index d44d0b2..46f421c 100644 --- a/sql/18-todo.sql +++ b/sql/18-todo.sql @@ -22,7 +22,7 @@ INSERT INTO status (status) VALUES("Revisar"); INSERT INTO status (status) VALUES("Reparación"); INSERT INTO status (status) VALUES("Mantenimiento"); -INSERT INTO carrera(id_carrera, carrera, clave) VALUES (1, 'PROFESOR', '1'); +INSERT INTO carrera(id_carrera, carrera, clave, id_nivel) VALUES (1, 'PROFESOR', '1'); INSERT INTO carrera(id_carrera, carrera, clave, id_nivel) VALUES(101, 'ACTUARIA', '101', 4); INSERT INTO carrera(id_carrera, carrera, clave, id_nivel) VALUES(102, 'ARQUITECTURA', '102', 4); INSERT INTO carrera(id_carrera, carrera, clave, id_nivel) VALUES(103, 'ARQUITECTURA DEL PAISAJE', '103', 4); diff --git a/src/institucion-carrera/dto/output/institucion-carrera.dto.ts b/src/institucion-carrera/dto/output/institucion-carrera.dto.ts index 9a4df65..0369aea 100644 --- a/src/institucion-carrera/dto/output/institucion-carrera.dto.ts +++ b/src/institucion-carrera/dto/output/institucion-carrera.dto.ts @@ -1,6 +1,6 @@ import { Expose, Type } from 'class-transformer'; import { CarreaOutputDto } from './carrera.dto'; -import { InstitucionesOutputDto } from '../../../institucion/dto/output/instituciones.dto'; +import { InstitucionMinOutputDto } from '../../../institucion/dto/output/institucion-min.dto'; export class InstitucionCarreaOutputDto { @Expose() @@ -14,6 +14,6 @@ export class InstitucionCarreaOutputDto { carrera; @Expose() - @Type(() => InstitucionesOutputDto) + @Type(() => InstitucionMinOutputDto) institucion; } diff --git a/src/institucion/dto/output/institucion-min.dto.ts b/src/institucion/dto/output/institucion-min.dto.ts new file mode 100644 index 0000000..4d89ef5 --- /dev/null +++ b/src/institucion/dto/output/institucion-min.dto.ts @@ -0,0 +1,9 @@ +import { Expose } from 'class-transformer'; + +export class InstitucionMinOutputDto { + @Expose() + id_institucion; + + @Expose() + institucion; +} diff --git a/src/institucion/dto/output/instituciones.dto.ts b/src/institucion/dto/output/instituciones.dto.ts index a6cdad9..c76df23 100644 --- a/src/institucion/dto/output/instituciones.dto.ts +++ b/src/institucion/dto/output/instituciones.dto.ts @@ -6,4 +6,10 @@ export class InstitucionesOutputDto { @Expose() institucion; + + @Expose() + dominio; + + @Expose() + email_institucional; } diff --git a/src/usuario/dto/usuario-dgae.dto.ts b/src/usuario/dto/input/dgae.dto.ts similarity index 100% rename from src/usuario/dto/usuario-dgae.dto.ts rename to src/usuario/dto/input/dgae.dto.ts diff --git a/src/usuario/dto/usuario-dgp.dto.ts b/src/usuario/dto/input/dgp.dto.ts similarity index 100% rename from src/usuario/dto/usuario-dgp.dto.ts rename to src/usuario/dto/input/dgp.dto.ts diff --git a/src/usuario/dto/usuario-registrar.dto.ts b/src/usuario/dto/input/registrar.dto.ts similarity index 100% rename from src/usuario/dto/usuario-registrar.dto.ts rename to src/usuario/dto/input/registrar.dto.ts diff --git a/src/usuario/dto/usuario-update.dto.ts b/src/usuario/dto/input/update.dto.ts similarity index 100% rename from src/usuario/dto/usuario-update.dto.ts rename to src/usuario/dto/input/update.dto.ts diff --git a/src/usuario/dto/usuario.dto.ts b/src/usuario/dto/input/usuario.dto.ts similarity index 100% rename from src/usuario/dto/usuario.dto.ts rename to src/usuario/dto/input/usuario.dto.ts diff --git a/src/usuario/dto/usuario-usuarios.dto.ts b/src/usuario/dto/input/usuarios.dto.ts similarity index 100% rename from src/usuario/dto/usuario-usuarios.dto.ts rename to src/usuario/dto/input/usuarios.dto.ts diff --git a/src/usuario/dto/output/escolares.dto.ts b/src/usuario/dto/output/escolares.dto.ts new file mode 100644 index 0000000..d0fb2c5 --- /dev/null +++ b/src/usuario/dto/output/escolares.dto.ts @@ -0,0 +1,22 @@ +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'; + +export class EscolaresOutputDto { + @Expose() + id_usuario; + + @Expose() + nombre; + + @Expose() + usuario; + + @Expose() + @Type(() => InstitucionCarreaOutputDto) + institucionCarrera; + + @Expose() + @Type(() => TipoUsuarioOutputDto) + tipoUsuario; +} diff --git a/src/usuario/dto/output/usuario.dto.ts b/src/usuario/dto/output/usuario.dto.ts new file mode 100644 index 0000000..3f390af --- /dev/null +++ b/src/usuario/dto/output/usuario.dto.ts @@ -0,0 +1,34 @@ +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'; + +export class UsuarioOutputDto { + @Expose() + activo; + + @Expose() + correo; + + @Expose() + id_usuario; + + @Expose() + multa; + + @Expose() + nombre; + + @Expose() + telefono; + + @Expose() + usuario; + + @Expose() + @Type(() => InstitucionCarreaOutputDto) + institucionCarrera; + + @Expose() + @Type(() => TipoUsuarioOutputDto) + tipoUsuario; +} diff --git a/src/usuario/dto/output/usuarios.dto.ts b/src/usuario/dto/output/usuarios.dto.ts new file mode 100644 index 0000000..0957260 --- /dev/null +++ b/src/usuario/dto/output/usuarios.dto.ts @@ -0,0 +1,22 @@ +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'; + +export class UsuariosOutputDto { + @Expose() + id_usuario; + + @Expose() + nombre; + + @Expose() + usuario; + + @Expose() + @Type(() => InstitucionCarreaOutputDto) + institucionCarrera; + + @Expose() + @Type(() => TipoUsuarioOutputDto) + tipoUsuario; +} diff --git a/src/usuario/usuario.controller.ts b/src/usuario/usuario.controller.ts index 8ebce1d..e081fb0 100644 --- a/src/usuario/usuario.controller.ts +++ b/src/usuario/usuario.controller.ts @@ -9,19 +9,24 @@ import { } from '@nestjs/common'; import { AuthGuard } from '@nestjs/passport'; import { ApiBody, ApiOperation, ApiQuery, ApiTags } from '@nestjs/swagger'; +import { Serealize } from '../interceptors/serialize.interceptor'; import { UsuarioService } from './usuario.service'; -import { UsuarioDgaeDto } from './dto/usuario-dgae.dto'; -import { UsuarioDgpDto } from './dto/usuario-dgp.dto'; -import { UsuarioRegistrarDto } from './dto/usuario-registrar.dto'; -import { UsuarioUpdateDto } from './dto/usuario-update.dto'; -import { UsuarioUsuariosDto } from './dto/usuario-usuarios.dto'; -import { UsuarioDto } from './dto/usuario.dto'; +import { UsuarioDgaeDto } from './dto/input/dgae.dto'; +import { UsuarioDgpDto } from './dto/input/dgp.dto'; +import { UsuarioRegistrarDto } from './dto/input/registrar.dto'; +import { UsuarioUpdateDto } from './dto/input/update.dto'; +import { UsuarioUsuariosDto } from './dto/input/usuarios.dto'; +import { UsuarioDto } from './dto/input/usuario.dto'; +import { EscolaresOutputDto } from './dto/output/escolares.dto'; +import { UsuarioOutputDto } from './dto/output/usuario.dto'; +import { UsuariosOutputDto } from './dto/output/usuarios.dto'; @Controller('usuario') @ApiTags('usuario') export class UsuarioController { constructor(private usuarioService: UsuarioService) {} + @Serealize(EscolaresOutputDto) @Get('dgae') @ApiOperation({ description: 'Endpoint que retorna información de dgae de un alumno.', @@ -43,6 +48,7 @@ export class UsuarioController { ); } + @Serealize(EscolaresOutputDto) @Get('dgp') @ApiOperation({ description: 'Endpoint que retorna información de dgp de un profesor.', @@ -113,6 +119,7 @@ export class UsuarioController { return this.usuarioService.passwordReset(body.id_usuario); } + @Serealize(UsuarioOutputDto) @Get('usuario') // @UseGuards(AuthGuard('jwt')) @ApiOperation({ @@ -127,6 +134,7 @@ export class UsuarioController { return this.usuarioService.findByUsuario(query.usuario, true, true); } + @Serealize(UsuariosOutputDto) @Get('usuarios') // @UseGuards(AuthGuard('jwt')) @ApiOperation({