Modificaciones en algunos endpoint y correcion de erroes
This commit is contained in:
@@ -146,6 +146,7 @@ export class ServicioController {
|
||||
@Body('data') dataJson: string,
|
||||
) {
|
||||
const body = JSON.parse(dataJson);
|
||||
console.log("file", file);
|
||||
return this.servicioService.subirCartaTermino(body.idServicio, file);
|
||||
}
|
||||
|
||||
|
||||
@@ -361,17 +361,32 @@ export class ServicioService {
|
||||
'id servicio',
|
||||
);
|
||||
|
||||
// Agregue estas lineas
|
||||
if (!archivo) {
|
||||
throw new BadRequestException('No se recibió el archivo');
|
||||
}
|
||||
|
||||
if (archivo.mimetype !== 'application/pdf') {
|
||||
throw new BadRequestException('El archivo debe ser PDF');
|
||||
}
|
||||
|
||||
const rutaArchivo = `./server/uploads/${archivo.originalname}`;
|
||||
// Hasta aqui termine de agregar las lineas
|
||||
|
||||
// 🔹 Validar archivo y generar path local
|
||||
const rutaArchivo: string = `./server/uploads/${this.validacionService.validacionBasicaStr(
|
||||
archivo,
|
||||
'archivo',
|
||||
true,
|
||||
1000,
|
||||
)}`;
|
||||
// const rutaArchivo: string = `./server/uploads/${this.validacionService.validacionBasicaStr(
|
||||
// archivo,
|
||||
// 'archivo',
|
||||
// true,
|
||||
// 1000,
|
||||
// )}`;
|
||||
|
||||
// 🔹 Buscar servicio
|
||||
const servicio = await this.servicioRepo.findOne({
|
||||
where: { idServicio },
|
||||
relations: {
|
||||
status: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!servicio) {
|
||||
@@ -1321,6 +1336,7 @@ export class ServicioService {
|
||||
.createQueryBuilder('servicio')
|
||||
.innerJoinAndSelect('servicio.usuario', 'usuario')
|
||||
.leftJoinAndSelect('usuario.tipoUsuario', 'tipoUsuario')
|
||||
.leftJoinAndSelect('servicio.cuestionarioPrograma2', 'cuestionarioPrograma2') // Agregue esta linea para tener la relacion y poder jalar la infromacion
|
||||
.innerJoinAndSelect('servicio.programa', 'programa')
|
||||
.innerJoinAndSelect('servicio.carrera', 'carrera')
|
||||
.innerJoinAndSelect('servicio.status', 'status')
|
||||
@@ -1354,6 +1370,7 @@ export class ServicioService {
|
||||
'carrera.carrera',
|
||||
'status.idStatus',
|
||||
'status.status',
|
||||
'cuestionarioPrograma2.idCuestionarioPrograma2', // Agrgue esta linea para tener la infromacion de la ralacion
|
||||
])
|
||||
.orderBy('servicio.createdAt', 'DESC') // Cambiamos el orderBy anteriormente orderBy('servicio.updatedAt', 'DESC')
|
||||
.skip(25 * (pagina - 1))
|
||||
@@ -1362,8 +1379,23 @@ export class ServicioService {
|
||||
// 5️⃣ Ejecutar y obtener datos + total
|
||||
const [rows, count] = await query.getManyAndCount();
|
||||
|
||||
// Agregue una validacion para el cuestionario de responsable
|
||||
const serviciosResponsable = rows.map((servicio) => ({
|
||||
...servicio,
|
||||
cuestionarioCompletado: Boolean(servicio.cuestionarioPrograma2),
|
||||
}));
|
||||
|
||||
// Agregamos temporalmente para verificar que funcione
|
||||
console.log(
|
||||
serviciosResponsable.map(s => ({
|
||||
idServicio: s.idServicio,
|
||||
cuestionarioCompleto: s.cuestionarioCompletado,
|
||||
}))
|
||||
)
|
||||
|
||||
// 6️⃣ Retornar resultado en el mismo formato que antes
|
||||
return { count, serviciosResponsable: rows };
|
||||
// return { count, serviciosResponsable: rows };
|
||||
return { count, serviciosResponsable };
|
||||
}
|
||||
|
||||
async update(
|
||||
|
||||
Reference in New Issue
Block a user