se arreglaron servicio y se agrego un controller para obtener todos los servicios
This commit is contained in:
Generated
+8
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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 || '',
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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<string> {
|
||||
// 🔹 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
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user