From 56f3eec287220410b2fda0d7763c5b577c6cc818 Mon Sep 17 00:00:00 2001 From: IO Date: Wed, 26 Jun 2024 20:31:50 -0600 Subject: [PATCH] fixed profe --- src/Profesor/profesor.service.ts | 2 +- src/auth/auth.controller.ts | 13 ++++++++++++- src/auth/auth.service.ts | 16 ++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/Profesor/profesor.service.ts b/src/Profesor/profesor.service.ts index 6c7c708..a94ce95 100644 --- a/src/Profesor/profesor.service.ts +++ b/src/Profesor/profesor.service.ts @@ -163,7 +163,7 @@ export class ProfesorService { async profile(id_profesor: number) { const profesor = await this.profesorRepository.findOne({ where: { id_profesor }, - relations: ['proyectosAcademicos', 'datosAcademicos', 'lineasInvestigacion'], + //relations: ['proyectosAcademicos', 'datosAcademicos', 'lineasInvestigacion'], }); if (!profesor) { diff --git a/src/auth/auth.controller.ts b/src/auth/auth.controller.ts index 2427563..02b8277 100644 --- a/src/auth/auth.controller.ts +++ b/src/auth/auth.controller.ts @@ -9,7 +9,8 @@ import { Put, Request, UseGuards, - Delete + Delete, + ParseIntPipe } from '@nestjs/common'; import { AuthGuard } from './auth.guard'; import { AuthService } from './auth.service'; @@ -64,4 +65,14 @@ export class AuthController { return this.authService.validateToken(token); } + @Get() + findAll() { + return this.authService.findAll(); + } + + @Get(':id_user') + async profile(@Param('id_user', ParseIntPipe) id_user: number) { + return this.authService.profile(id_user); + } + } \ No newline at end of file diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts index 6dd715f..f3d0e2d 100644 --- a/src/auth/auth.service.ts +++ b/src/auth/auth.service.ts @@ -108,4 +108,20 @@ export class AuthService { throw new UnauthorizedException('validation token failed'); } } + + async findAll(): Promise { + return this.userRepository.find(); + } + + async profile(id_usuario: number) { + const user = await this.userRepository.findOne({ + where: { id_usuario }, + }); + + if (!user) { + throw new HttpException('user not found', 404); + } + + return user; + } }