diff --git a/package-lock.json b/package-lock.json index 3762584..1dfa050 100644 --- a/package-lock.json +++ b/package-lock.json @@ -48,6 +48,7 @@ "@swc/core": "^1.13.5", "@types/express": "^5.0.3", "@types/jest": "^30.0.0", + "@types/moment": "^2.11.29", "@types/multer": "^2.0.0", "@types/node": "^24.5.2", "@types/supertest": "^6.0.3", @@ -3450,6 +3451,13 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/moment": { + "version": "2.11.29", + "resolved": "https://registry.npmjs.org/@types/moment/-/moment-2.11.29.tgz", + "integrity": "sha512-D5WIgbLYQzvgfsDnBhZFSTnt/BjGPOE+Jsh3k1BYYijJAkrn7ceeLvU4jtjKKXXuXN42O3ARlU4D/P9ezbQYFA==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/ms": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/@types/ms/-/ms-2.1.0.tgz", diff --git a/package.json b/package.json index d7a18da..0d18363 100644 --- a/package.json +++ b/package.json @@ -59,6 +59,7 @@ "@swc/core": "^1.13.5", "@types/express": "^5.0.3", "@types/jest": "^30.0.0", + "@types/moment": "^2.11.29", "@types/multer": "^2.0.0", "@types/node": "^24.5.2", "@types/supertest": "^6.0.3", diff --git a/server/uploads/2020_gustavo_baz_prada.csv b/server/uploads/2020_gustavo_baz_prada.csv new file mode 100644 index 0000000..e69de29 diff --git a/server/uploads/2024_gustavo_baz_prada.csv b/server/uploads/2024_gustavo_baz_prada.csv new file mode 100644 index 0000000..e69de29 diff --git a/server/uploads/2025_gustavo_baz_prada.csv b/server/uploads/2025_gustavo_baz_prada.csv new file mode 100644 index 0000000..e69de29 diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts index 4a3f71b..b21f504 100644 --- a/src/auth/auth.service.ts +++ b/src/auth/auth.service.ts @@ -75,7 +75,7 @@ export class AuthService { async login(usuario: string, password: string) { const user = await this.userRepo.findOne({ where: { usuario }, - relations: ['tipoUsuario'], // ✅ Cargar la relación + relations: ['tipoUsuario'], }); if (!user) throw new UnauthorizedException('No existe este usuario.'); @@ -85,11 +85,22 @@ export class AuthService { if (!user.activo) throw new Error('Este usuario no esta activo.'); - // ✅ Ahora user.tipoUsuario debería estar definido const token = await this.jwtCreate( user.idUsuario, - user.tipoUsuario.idTipoUsuario, // Ya no será undefined + user.tipoUsuario.idTipoUsuario, ); - return token; + + return { + token: token.access_token, + Usuario: { + idUsuario: user.idUsuario, + usuario: user.usuario, + nombre: user.nombre || '', + TipoUsuario: { + idTipoUsuario: user.tipoUsuario.idTipoUsuario, + tipoUsuario: user.tipoUsuario.tipoUsuario || '', + }, + }, + }; } } diff --git a/src/servicio/servicio.controller.ts b/src/servicio/servicio.controller.ts index a60c319..7a09c16 100644 --- a/src/servicio/servicio.controller.ts +++ b/src/servicio/servicio.controller.ts @@ -41,8 +41,14 @@ export class ServicioController { // ------------------ GET ------------------ + @Get('todos') + @UseGuards(AuthGuard('jwt')) + async obtenerTodosLosServicios() { + return this.servicioService.obtenerTodosLosServicios(); + } + @Get('admin/:idServicio') - //@UseGuards(AuthGuard('jwt')) + @UseGuards(AuthGuard('jwt')) async obtenerAdmin(@Param('idServicio') idServicio: number) { return this.servicioService.obtenerDetalleServicio(idServicio); } diff --git a/src/servicio/servicio.service.ts b/src/servicio/servicio.service.ts index dca48fb..0271bbc 100644 --- a/src/servicio/servicio.service.ts +++ b/src/servicio/servicio.service.ts @@ -12,7 +12,7 @@ import { Usuario } from 'src/usuario/entities/usuario.entity'; import { ValidacionService } from 'src/helpers.services/validacion.service'; import { gmail } from 'src/helpers.services/gmail.service'; import { DriveService } from 'src/drive/drive.service'; -import moment from 'moment'; +import * as moment from 'moment'; import { ArchivoService } from 'src/helpers.services/archivo.service'; import { convertArrayToCSV } from 'convert-array-to-csv'; import { Programa } from 'src/programa/entities/programa.entity'; @@ -53,8 +53,8 @@ export class ServicioService { async obtenerServicioAlumno(idUsuario: number) { const usuario = await this.usuarioRepo.findOne({ where: { idUsuario }, + relations: ['tipoUsuario'], }); - if (!usuario) { throw new NotFoundException('No existe este usuario.'); } @@ -67,7 +67,7 @@ export class ServicioService { .createQueryBuilder('servicio') .leftJoinAndSelect('servicio.carrera', 'carrera') .leftJoinAndSelect('servicio.status', 'status') - .leftJoinAndSelect('servicio.programas', 'programa') + .leftJoinAndSelect('servicio.programa', 'programa') .where('servicio.idUsuario = :idUsuario', { idUsuario }) .andWhere('servicio.idStatus != :status', { status: 10 }) .select([ @@ -94,10 +94,10 @@ export class ServicioService { 'programa.clavePrograma', 'carrera.idCarrera', - 'carrera.nombre', + 'carrera.carrera', 'status.idStatus', - 'status.descripcion', + 'status.status', ]) .getOne(); @@ -416,7 +416,7 @@ export class ServicioService { async generarGustavoBazPrada(yearParam: number): Promise { // 🔹 Validar año const year: number = this.validacionService.validarNumero( - yearParam, + String(yearParam), 'año', true, 4, @@ -1434,4 +1434,13 @@ export class ServicioService { message: 'Se guardaron correctamente los cambios de este servicio.', }; } + + async obtenerTodosLosServicios() { + return await this.servicioRepo.find({ + relations: ['usuario', 'carrera', 'status', 'programa'], + order: { + idServicio: 'DESC', // Ordenar por el más reciente primero + }, + }); + } }