Se modificaron varias cosas en los endpoint y en algunas entities asi como en los dto

This commit is contained in:
santiago
2025-12-09 09:03:52 -06:00
parent 3e67102878
commit 7a260169cc
16 changed files with 14030 additions and 13923 deletions
+1 -1
View File
@@ -27,7 +27,7 @@ import { AuthModule } from './auth/auth.module';
database: process.env.DB_DATABASE,
password: process.env.DB_PASSWORD,
port: Number(process.env.DB_PORT),
synchronize: true,
synchronize: false, //Lo ponemos en false para no afectar
dropSchema: false,
autoLoadEntities: true,
logger: 'advanced-console',
+2 -2
View File
@@ -139,11 +139,11 @@ export class CasoEspecialService {
}
if (nombre) {
query.andWhere('usuario.nombre ILIKE :nombre', { nombre: `%${nombre}%` });
query.andWhere('usuario.nombre LIKE :nombre', { nombre: `%${nombre}%` });
}
if (numeroCuenta) {
query.andWhere('usuario.usuario ILIKE :numeroCuenta', {
query.andWhere('usuario.usuario LIKE :numeroCuenta', {
numeroCuenta: `%${numeroCuenta}%`,
});
}
@@ -8,12 +8,14 @@ import {
Delete,
UseGuards,
Query,
Res,
} from '@nestjs/common';
import { CuestionarioAlumno2Service } from './cuestionario-alumno2.service';
import { CreateCuestionarioAlumno2Dto } from './dto/create-cuestionario-alumno2.dto';
import { AuthGuard } from '@nestjs/passport';
import { findCuestionarioAlumno2Dto } from './dto/find.dto';
import { Response } from 'express';
@Controller('cuestionario-alumno2')
export class CuestionarioAlumno2Controller {
@@ -29,8 +31,10 @@ export class CuestionarioAlumno2Controller {
@Get()
@UseGuards(AuthGuard('jwt'))
findAll(@Query() findDto: findCuestionarioAlumno2Dto) {
return this.cuestionarioAlumno2Service.get(findDto.version, findDto.anio);
async findAll(@Query() findDto: findCuestionarioAlumno2Dto, @Res() res: Response) {
const path = await this.cuestionarioAlumno2Service.get(findDto.version, findDto.anio);
return res.download(path);
}
// @Get(':id')
@@ -69,6 +69,7 @@ export class CuestionarioAlumno2Service {
return resX;
}
/*
async get(version: string, anio: string) {
const year = anio;
const path = `server/uploads/${year}_cuestionario_alumno.csv`;
@@ -106,4 +107,44 @@ export class CuestionarioAlumno2Service {
return this.archivoService.crearArchivo(path, convertArrayToCSV(data));
}
*/
async get(version: string, anio: string): Promise<string> {
const path = `server/uploads/${anio}_cuestionario_alumno.csv`;
let temp;
if (version === 'v1') {
temp = await this.cuestionarioAlumnoRepository.find({
where: {
idCuestionarioAlumno: Not(IsNull()),
},
});
}
if (version === 'v2') {
temp = await this.cuestionarioAlumno2Repository.find({
where: {
idCuestionarioAlumno2: Not(IsNull()),
},
});
}
if (!temp || temp.length === 0) {
throw new Error('No hay datos para exportar');
}
const data = temp.map((item) => ({ ...item }));
await this.archivoService.eliminarArchivo(path).catch(() => null);
// ✅ Creamos el archivo
await this.archivoService.crearArchivo(
path,
convertArrayToCSV(data),
);
// ✅ SOLO regresamos el path
return path;
}
}
+1
View File
@@ -272,6 +272,7 @@ ${atentamente}
};
};
// Quitamos el module para que podamos exportar normal anteriormente module.export
module.exports = {
preRegistro,
preRegistroRechazadoAlumno,
+1
View File
@@ -208,6 +208,7 @@ export class ProgramaService {
const usuario = await this.usuarioRepo.findOne({
where: { idUsuario },
relations: ['tipoUsuario'], // Se agrego la relacion con tipo de usuario
});
if (!usuario) {
+4 -4
View File
@@ -26,11 +26,11 @@ export class CrearServicioDto {
@IsEmail()
correo: string;
@IsDate()
fechaInicio: Date;
@IsDateString()
fechaInicio: string; // Cambiado a string antes tenia Date
@IsDate()
fechaFin: Date;
@IsDateString()
fechaFin: string; // Cambiado a string antes tenia Date
@IsOptional()
@IsString()
+1 -1
View File
@@ -12,7 +12,7 @@ export class RegistroValidadoDto {
idServicio: number;
@IsOptional()
fechaNacimiento?: Date;
fechaNacimiento?: string; // Lo pasamos a string antes date
@IsOptional()
@IsString()
+3 -3
View File
@@ -20,17 +20,17 @@ export class UpdateServicioDto {
@IsOptional()
@IsDateString({}, { message: 'fechaInicio debe ser una fecha válida' })
//@Type(() => Date)
fechaInicio?: Date;
fechaInicio?: string; // Lo pasamos a string antes date
@IsOptional()
@IsDateString({}, { message: 'fechaFin debe ser una fecha válida' })
//@Type(() => Date)
fechaFin?: Date;
fechaFin?: string; // Lo pasamos a string antes date
@IsOptional()
@IsDateString({}, { message: 'fechaNacimiento debe ser una fecha válida' })
//@Type(() => Date)
fechaNacimiento?: Date;
fechaNacimiento?: string; // Lo pasamos a string antes date
@IsOptional()
@IsString({ message: 'direccion debe ser texto' })
+5 -5
View File
@@ -34,19 +34,19 @@ export class Servicio {
direccion?: string;
@Column({ type: 'date' })
fechaInicio: Date;
fechaInicio: string; // Cambios a tipo string antes tenia date
@Column({ type: 'date' })
fechaFin: Date;
fechaFin: string; // Cambios a tipo string antes tenia date
@Column({ type: 'date', nullable: true, default: null })
fechaLiberacion?: Date;
fechaLiberacion?: string; // Cambios a tipo string antes tenia date
@Column({ type: 'date', nullable: true, default: null })
fechaNacimiento?: Date;
fechaNacimiento?: string; // Cambios a tipo string antes tenia date
@Column({ type: 'varchar', length: 60 })
carpeta: string;
carpeta: string;
@Column({ type: 'varchar', length: 60 })
cartaAceptacion: string;
+6 -2
View File
@@ -83,10 +83,14 @@ export class ServicioController {
return res.download(path);
}
// Corregi el endpoint tenia llamando a otrea funcion
@Get('reporte')
@UseGuards(AuthGuard('jwt'))
async generarReporte(@Query() query: any, @Res() res: Response) {
const path = await this.servicioService.generarGustavoBazPrada(query.year);
async generarReporte(
@Query('inicio') inicio: string,
@Query('fin') fin: string,
@Res() res: Response) {
const path = await this.servicioService.generarReporte(inicio, fin);
return res.download(path);
}
+24 -9
View File
@@ -22,7 +22,11 @@ import { RegistroValidadoDto } from './dto/registro-validado.dto';
import * as fs from 'fs';
import { ServiciosAdminDto } from './dto/servicios-admin.dto';
import { ServiciosResponsableDto } from './dto/servicios-responsable.dto';
import { SendMailDto } from 'src/helpers.services/dto/send-email.dto';
import { SendMailDto } from 'src/helpers.services/dto/send-email.dto';
const {
canceladoAlumno,
canceladoResponsable,
} = require('./../helpers.services/msjCorreos');
@Injectable()
export class ServicioService {
@@ -189,6 +193,7 @@ export class ServicioService {
'usuario', // alumno
'programa',
'programa.usuario', // responsable
'status', // Falto agregar la relacion de status
],
});
@@ -196,6 +201,11 @@ export class ServicioService {
throw new NotFoundException('No existe este Servicio Social.');
}
// Agregamos una validación para el status extra
if (!servicio.status) {
throw new BadRequestException('El Servicio Social no tiene un estatus válido.');
}
if (servicio.status.idStatus === 10) {
throw new BadRequestException('Este Servicio Social ya fue cancelado.');
}
@@ -422,8 +432,11 @@ export class ServicioService {
4,
);
const inicio = moment(`${year}-01-31`).toDate();
const fin = moment(`${year + 1}-01-31`).toDate();
// Los transformo a string para hacer la consulta
//const inicio = moment(`${year}-01-31`).toDate();
//const fin = moment(`${year + 1}-01-31`).toDate();
const inicio = moment(`${year}-01-31`).format('YYYY-MM-DD');
const fin = moment(`${year + 1}-01-31`).format('YYYY-MM-DD');
const path: string = `server/uploads/${year}_gustavo_baz_prada.csv`;
const data: any[] = [];
@@ -614,7 +627,7 @@ export class ServicioService {
// 🔹 Actualizar el servicio
await this.servicioRepo.update(idServicio, {
status: { idStatus: 6 },
fechaLiberacion: moment().toDate(),
fechaLiberacion: moment().format('YYYY-MM-DD'), // lo mismo pasamos a string antes como toDate
vistoBuenoAcatlan: vistoBuenoAcatlan ? true : false,
});
@@ -1185,7 +1198,8 @@ export class ServicioService {
};
}
async generarReporte(inicio: Date, fin: Date): Promise<string> {
// Pasamos el string antes tenia Date
async generarReporte(inicio: string, fin: string): Promise<string> {
const path = `server/uploads/reporte.csv`;
const data: any[] = [];
@@ -1345,7 +1359,7 @@ export class ServicioService {
'status.idStatus',
'status.status',
])
.orderBy('servicio.updatedAt', 'DESC')
.orderBy('servicio.createdAt', 'DESC') // Cambiamos el orderBy anteriormente orderBy('servicio.updatedAt', 'DESC')
.skip(25 * (pagina - 1))
.take(25);
@@ -1413,9 +1427,6 @@ export class ServicioService {
// ---- 📆 Validaciones de campos del body ----
if (body.correo) dataUpdate.correo = body.correo;
if (body.fechaInicio) dataUpdate.fechaInicio = body.fechaInicio;
if (body.fechaFin) dataUpdate.fechaFin = body.fechaFin;
if (body.fechaNacimiento) dataUpdate.fechaNacimiento = body.fechaNacimiento;
if (body.direccion)
dataUpdate.direccion = this.validacionService.validarAlfanumerico(
body.direccion,
@@ -1431,6 +1442,10 @@ export class ServicioService {
15,
);
if (body.fechaInicio) dataUpdate.fechaInicio = moment(body.fechaInicio).format('YYYY-MM-DD');
if (body.fechaFin) dataUpdate.fechaFin = moment(body.fechaFin).format('YYYY-MM-DD');
if (body.fechaNacimiento) dataUpdate.fechaNacimiento = moment(body.fechaNacimiento).format('YYYY-MM-DD');
if (this.validacionService.validarObjetoVacio(dataUpdate)) {
throw new BadRequestException(
'No se envió nada para actualizar este Servicio Social.',
+11 -1
View File
@@ -66,7 +66,9 @@ export class UsuarioService {
let response;
try {
if (process.env.MODE == 'pruebas') {
response = new Promise((res) => {
/*
Quitamos la promesa ya que muestra un error
response = new Promise((res) => {
res({
data: {
nombre: 'nombre',
@@ -75,6 +77,14 @@ export class UsuarioService {
},
});
});
*/
response = {
data: {
nombre: 'nombre',
carrconst: 'Carrera',
avance: '80',
},
};
} else {
response = await axios.post(
`${process.env.ESCOLARES}${numeroDeCuenta}`,