fixed profe

This commit is contained in:
IO
2024-06-26 20:31:50 -06:00
parent cc7473ebd2
commit 56f3eec287
3 changed files with 29 additions and 2 deletions
+1 -1
View File
@@ -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) {
+12 -1
View File
@@ -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);
}
}
+16
View File
@@ -108,4 +108,20 @@ export class AuthService {
throw new UnauthorizedException('validation token failed');
}
}
async findAll(): Promise<User[]> {
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;
}
}