Se corrigió envio de correos y creacion de controller servicio
This commit is contained in:
@@ -19,15 +19,15 @@ export class UpdateServicioDto {
|
||||
|
||||
@IsOptional()
|
||||
@IsDateString({}, { message: 'fechaInicio debe ser una fecha válida' })
|
||||
fechaInicio?: string;
|
||||
fechaInicio?: Date;
|
||||
|
||||
@IsOptional()
|
||||
@IsDateString({}, { message: 'fechaFin debe ser una fecha válida' })
|
||||
fechaFin?: string;
|
||||
fechaFin?: Date;
|
||||
|
||||
@IsOptional()
|
||||
@IsDateString({}, { message: 'fechaNacimiento debe ser una fecha válida' })
|
||||
fechaNacimiento?: string;
|
||||
fechaNacimiento?: Date;
|
||||
|
||||
@IsOptional()
|
||||
@IsString({ message: 'direccion debe ser texto' })
|
||||
|
||||
@@ -1,34 +1,158 @@
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
||||
import {
|
||||
Controller,
|
||||
Get,
|
||||
Post,
|
||||
Put,
|
||||
Body,
|
||||
Query,
|
||||
UploadedFile,
|
||||
UploadedFiles,
|
||||
UseGuards,
|
||||
UseInterceptors,
|
||||
Res,
|
||||
ParseIntPipe,
|
||||
} from '@nestjs/common';
|
||||
import {
|
||||
FileInterceptor,
|
||||
FileFieldsInterceptor,
|
||||
} from '@nestjs/platform-express';
|
||||
import { ServicioService } from './servicio.service';
|
||||
import { CreateServicioDto } from './dto/create-servicio.dto';
|
||||
import { UpdateServicioDto } from './dto/update-servicio.dto';
|
||||
import { AuthGuard } from '@nestjs/passport';
|
||||
import { CrearServicioDto } from './dto/create-servicio.dto';
|
||||
import { Response } from 'express';
|
||||
|
||||
@Controller('servicio')
|
||||
export class ServicioController {
|
||||
constructor(private readonly servicioService: ServicioService) {}
|
||||
|
||||
@Post()
|
||||
create(@Body() createServicioDto: CreateServicioDto) {
|
||||
return this.servicioService.create(createServicioDto);
|
||||
// ------------------ POST ------------------
|
||||
|
||||
@Post('nuevo')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@UseInterceptors(FileInterceptor('cartaAceptacion'))
|
||||
async crearServicio(
|
||||
@UploadedFile() file: Express.Multer.File,
|
||||
@Body('alumno') alumnoJson: string,
|
||||
) {
|
||||
const dto: CrearServicioDto = JSON.parse(alumnoJson);
|
||||
return await this.servicioService.registrarNuevoServicio(dto, file);
|
||||
}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.servicioService.findAll();
|
||||
// ------------------ GET ------------------
|
||||
|
||||
@Get('admin')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
async obtenerAdmin(@Query() query: any) {
|
||||
return this.servicioService.obtenerDetalleServicio(query.idServicio);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.servicioService.findOne(+id);
|
||||
@Get('alumno')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
async obtenerAlumno(@Query('idUsuario', ParseIntPipe) idUsuario: number) {
|
||||
return this.servicioService.obtenerServicioAlumno(idUsuario);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
update(@Param('id') id: string, @Body() updateServicioDto: UpdateServicioDto) {
|
||||
return this.servicioService.update(+id, updateServicioDto);
|
||||
@Get('gustavo_baz_prada')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
async gustavoBaz(
|
||||
@Query('year', ParseIntPipe) year: number,
|
||||
@Res() res: Response,
|
||||
) {
|
||||
const path = await this.servicioService.generarGustavoBazPrada(year);
|
||||
return res.download(path);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
remove(@Param('id') id: string) {
|
||||
return this.servicioService.remove(+id);
|
||||
@Get('reporte')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
async generarReporte(@Query() query: any, @Res() res: Response) {
|
||||
const path = await this.servicioService.generarGustavoBazPrada(query.year);
|
||||
return res.download(path);
|
||||
}
|
||||
|
||||
// ------------------ PUT ------------------
|
||||
|
||||
@Put('cancelar')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
async cancelar(@Body() body: { idServicio: number; mensaje: string }) {
|
||||
return this.servicioService.cancelarServicio(body);
|
||||
}
|
||||
|
||||
@Put('carta_aceptacion')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@UseInterceptors(FileInterceptor('cartaAceptacion'))
|
||||
async subirCartaAceptacion(
|
||||
@UploadedFile() file: Express.Multer.File,
|
||||
@Body('data') dataJson: string,
|
||||
) {
|
||||
const body = JSON.parse(dataJson);
|
||||
return this.servicioService.cartaTermino(body.idServicio, file);
|
||||
}
|
||||
|
||||
@Put('carta_termino')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@UseInterceptors(FileInterceptor('cartaTermino'))
|
||||
async subirCartaTermino(
|
||||
@UploadedFile() file: Express.Multer.File,
|
||||
@Body('data') dataJson: string,
|
||||
) {
|
||||
const body = JSON.parse(dataJson);
|
||||
return this.servicioService.subirCartaTermino(body.idServicio, file);
|
||||
}
|
||||
|
||||
@Put('informe_global')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@UseInterceptors(FileInterceptor('informeGlobal'))
|
||||
async subirInformeGlobal(
|
||||
@UploadedFile() file: Express.Multer.File,
|
||||
@Body('data') dataJson: string,
|
||||
) {
|
||||
const body = JSON.parse(dataJson);
|
||||
return this.servicioService.subirInformeGlobal(body.idServicio, file);
|
||||
}
|
||||
|
||||
@Put('liberacion')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
async liberarServicio(
|
||||
@Body('idServicio', ParseIntPipe) idServicio: number,
|
||||
@Body('vistoBuenoAcatlan') vistoBuenoAcatlan: boolean,
|
||||
) {
|
||||
return this.servicioService.liberarServicio(idServicio, vistoBuenoAcatlan);
|
||||
}
|
||||
|
||||
@Put('rechazar_aceptacion')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
async rechazarAceptacion(
|
||||
@Body() body: { idServicio: number; mensaje: string },
|
||||
) {
|
||||
return this.servicioService.rechazar(body.idServicio, body.mensaje);
|
||||
}
|
||||
|
||||
@Put('rechazar_informe')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
async rechazarInforme(@Body() body: { idServicio: number; mensaje: string }) {
|
||||
return this.servicioService.rechazarInforme(body.idServicio, body.mensaje);
|
||||
}
|
||||
|
||||
@Put('rechazar_termino')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
async rechazarTermino(@Body() body: { idServicio: number; mensaje: string }) {
|
||||
return this.servicioService.rechazarTermino(body.idServicio, body.mensaje);
|
||||
}
|
||||
|
||||
@Put('update')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@UseInterceptors(
|
||||
FileFieldsInterceptor([
|
||||
{ name: 'cartaAceptacion', maxCount: 1 },
|
||||
{ name: 'cartaTermino', maxCount: 1 },
|
||||
{ name: 'informeGlobal', maxCount: 1 },
|
||||
]),
|
||||
)
|
||||
async actualizarServicio(
|
||||
@UploadedFiles() files: Record<string, Express.Multer.File[]>,
|
||||
@Body('data') dataJson: string,
|
||||
) {
|
||||
const data = JSON.parse(dataJson);
|
||||
return this.servicioService.update(data, files);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import { Servicio } from './entities/servicio.entity';
|
||||
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 { SendCorreoDto } from 'src/helpers.services/dto/send-email.dto';
|
||||
import { DriveService } from 'src/drive/drive.service';
|
||||
import moment from 'moment';
|
||||
import { ArchivoService } from 'src/helpers.services/archivo.service';
|
||||
@@ -22,6 +21,8 @@ import { AuthService } from 'src/auth/auth.service';
|
||||
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';
|
||||
|
||||
@Injectable()
|
||||
export class ServicioService {
|
||||
@@ -211,7 +212,7 @@ export class ServicioService {
|
||||
const correoAlumno = canceladoAlumno(mensaje, alumno.nombre);
|
||||
const correoResponsable = canceladoResponsable(mensaje, alumno.nombre);
|
||||
|
||||
const sendCorreoAlumnoDto: SendCorreoDto = {
|
||||
const sendCorreoAlumnoDto: SendMailDto = {
|
||||
to: servicio.correo,
|
||||
subject: correoAlumno.subject,
|
||||
fecha_recibido: new Date(),
|
||||
@@ -220,7 +221,7 @@ export class ServicioService {
|
||||
adjuntos: undefined,
|
||||
};
|
||||
|
||||
const sendCorreoResponsableDto: SendCorreoDto = {
|
||||
const sendCorreoResponsableDto: SendMailDto = {
|
||||
to: responsable.usuario,
|
||||
subject: correoResponsable.subject,
|
||||
fecha_recibido: new Date(),
|
||||
@@ -234,17 +235,11 @@ export class ServicioService {
|
||||
}
|
||||
|
||||
if (servicio.correo) {
|
||||
await this.gmailService.send(
|
||||
sendCorreoAlumnoDto,
|
||||
process.env.TOKEN_GMAIL,
|
||||
);
|
||||
await this.gmailService.enviarCorreo(sendCorreoAlumnoDto);
|
||||
}
|
||||
|
||||
if (responsable.usuario) {
|
||||
await this.gmailService.send(
|
||||
sendCorreoResponsableDto,
|
||||
process.env.TOKEN_GMAIL,
|
||||
);
|
||||
await this.gmailService.enviarCorreo(sendCorreoResponsableDto);
|
||||
}
|
||||
|
||||
// Desactivar al usuario (alumno)
|
||||
@@ -588,16 +583,12 @@ export class ServicioService {
|
||||
const correoAlumno = terminoValidado(servicio.usuario.nombre);
|
||||
|
||||
if (servicio.correo) {
|
||||
await this.gmailService.sendMail(
|
||||
{
|
||||
to: servicio.correo,
|
||||
subject: correoAlumno.subject,
|
||||
text: correoAlumno.msj,
|
||||
html: '',
|
||||
fecha_recibido: new Date(),
|
||||
},
|
||||
process.env.TOKEN_GMAIL,
|
||||
);
|
||||
await this.gmailService.enviarCorreo({
|
||||
to: servicio.correo,
|
||||
subject: correoAlumno.subject,
|
||||
text: correoAlumno.msj,
|
||||
fecha_recibido: new Date(),
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -763,11 +754,12 @@ export class ServicioService {
|
||||
emailResponsable = servicio.programa.usuario.usuario; // correo del responsable
|
||||
|
||||
// Enviar correo al alumno
|
||||
await this.gmailService.enviarCorreo(
|
||||
correoAlumno.subject,
|
||||
servicio.correo,
|
||||
correoAlumno.msj,
|
||||
);
|
||||
await this.gmailService.enviarCorreo({
|
||||
subject: correoAlumno.subject,
|
||||
to: servicio.correo,
|
||||
text: correoAlumno.msj,
|
||||
fecha_recibido: new Date(),
|
||||
});
|
||||
break;
|
||||
|
||||
case 2:
|
||||
@@ -796,11 +788,12 @@ export class ServicioService {
|
||||
}
|
||||
|
||||
// Enviar correo al responsable
|
||||
await this.gmailService.enviarCorreo(
|
||||
correoResponsable.subject,
|
||||
emailResponsable,
|
||||
correoResponsable.msj,
|
||||
);
|
||||
await this.gmailService.enviarCorreo({
|
||||
subject: correoResponsable.subject,
|
||||
to: emailResponsable,
|
||||
text: correoResponsable.msj,
|
||||
fecha_recibido: new Date(),
|
||||
});
|
||||
|
||||
// Actualizar estado del servicio
|
||||
await this.servicioRepo.update(idServicio, {
|
||||
@@ -836,11 +829,12 @@ export class ServicioService {
|
||||
);
|
||||
emailResponsable = servicio.programa.usuario.usuario; // correo responsable
|
||||
|
||||
await this.gmailService.enviarCorreo(
|
||||
correoAlumno.subject,
|
||||
servicio.correo,
|
||||
correoAlumno.msj,
|
||||
);
|
||||
await this.gmailService.enviarCorreo({
|
||||
subject: correoAlumno.subject,
|
||||
to: servicio.correo,
|
||||
text: correoAlumno.msj,
|
||||
fecha_recibido: new Date(),
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -874,11 +868,12 @@ export class ServicioService {
|
||||
}
|
||||
|
||||
// Enviar correo al responsable
|
||||
await this.gmailService.enviarCorreo(
|
||||
correoResponsable.subject,
|
||||
emailResponsable,
|
||||
correoResponsable.msj,
|
||||
);
|
||||
await this.gmailService.enviarCorreo({
|
||||
subject: correoResponsable.subject,
|
||||
to: emailResponsable,
|
||||
text: correoResponsable.msj,
|
||||
fecha_recibido: new Date(),
|
||||
});
|
||||
|
||||
// Actualizar estado del servicio
|
||||
await this.servicioRepo.update(idServicio, {
|
||||
@@ -916,11 +911,12 @@ export class ServicioService {
|
||||
);
|
||||
emailResponsable = servicio.programa.usuario.usuario;
|
||||
|
||||
await this.gmailService.enviarCorreo(
|
||||
correoAlumno.subject,
|
||||
servicio.correo,
|
||||
correoAlumno.msj,
|
||||
);
|
||||
await this.gmailService.enviarCorreo({
|
||||
subject: correoAlumno.subject,
|
||||
to: servicio.correo,
|
||||
text: correoAlumno.msj,
|
||||
fecha_recibido: new Date(),
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -954,11 +950,12 @@ export class ServicioService {
|
||||
}
|
||||
|
||||
// Enviar correo al responsable
|
||||
await this.gmailService.enviarCorreo(
|
||||
correoResponsable.subject,
|
||||
emailResponsable,
|
||||
correoResponsable.msj,
|
||||
);
|
||||
await this.gmailService.enviarCorreo({
|
||||
subject: correoResponsable.subject,
|
||||
to: emailResponsable,
|
||||
text: correoResponsable.msj,
|
||||
fecha_recibido: new Date(),
|
||||
});
|
||||
|
||||
// Actualizar el servicio
|
||||
await this.servicioRepo.update(idServicio, {
|
||||
@@ -988,11 +985,12 @@ export class ServicioService {
|
||||
case 1:
|
||||
correoData = preRegistro(password, servicio.usuario.nombre);
|
||||
idUsuario = servicio.usuario.idUsuario;
|
||||
await this.gmailService.enviarCorreo(
|
||||
correoData.subject,
|
||||
servicio.correo,
|
||||
correoData.msj,
|
||||
);
|
||||
await this.gmailService.enviarCorreo({
|
||||
subject: correoData.subject,
|
||||
to: servicio.correo,
|
||||
text: correoData.msj,
|
||||
fecha_recibido: new Date(),
|
||||
});
|
||||
break;
|
||||
|
||||
case 2:
|
||||
@@ -1061,11 +1059,12 @@ export class ServicioService {
|
||||
servicio.usuario.nombre,
|
||||
);
|
||||
emailResponsable = servicio.programa.usuario.usuario;
|
||||
await this.gmailService.enviarCorreo(
|
||||
correoAlumno.subject,
|
||||
servicio.correo,
|
||||
correoAlumno.msj,
|
||||
);
|
||||
await this.gmailService.enviarCorreo({
|
||||
subject: correoAlumno.subject,
|
||||
to: servicio.correo,
|
||||
text: correoAlumno.msj,
|
||||
fecha_recibido: new Date(),
|
||||
});
|
||||
break;
|
||||
|
||||
case 1:
|
||||
@@ -1097,11 +1096,12 @@ export class ServicioService {
|
||||
throw new BadRequestException('Id status no válido.');
|
||||
}
|
||||
|
||||
await this.gmailService.enviarCorreo(
|
||||
correoResponsable.subject,
|
||||
emailResponsable,
|
||||
correoResponsable.msj,
|
||||
);
|
||||
await this.gmailService.enviarCorreo({
|
||||
subject: correoResponsable.subject,
|
||||
to: emailResponsable,
|
||||
text: correoResponsable.msj,
|
||||
fecha_recibido: new Date(),
|
||||
});
|
||||
|
||||
// Determinar estatus según modo
|
||||
const tempStatus = process.env.MODE === 'pruebas' ? 4 : 3;
|
||||
@@ -1202,4 +1202,169 @@ export class ServicioService {
|
||||
|
||||
return { count, serviciosAdmin: servicios };
|
||||
}
|
||||
|
||||
async obtenerServiciosResponsable(dto: ServiciosResponsableDto) {
|
||||
const {
|
||||
idUsuario,
|
||||
idStatus,
|
||||
nombre = '',
|
||||
numeroCuenta = '',
|
||||
pagina = 1,
|
||||
} = dto;
|
||||
|
||||
// 1️⃣ Validar que el usuario exista y sea responsable
|
||||
const responsable = await this.usuarioRepo.findOne({
|
||||
where: { idUsuario },
|
||||
});
|
||||
if (!responsable) throw new NotFoundException('No existe este usuario.');
|
||||
if (responsable.tipoUsuario.idTipoUsuario !== 2)
|
||||
throw new BadRequestException('No es un usuario tipo responsable.');
|
||||
|
||||
// 2️⃣ Crear el query builder
|
||||
const query = this.servicioRepo
|
||||
.createQueryBuilder('servicio')
|
||||
.innerJoinAndSelect('servicio.usuario', 'usuario')
|
||||
.innerJoinAndSelect('servicio.programa', 'programa')
|
||||
.innerJoinAndSelect('servicio.carrera', 'carrera')
|
||||
.innerJoinAndSelect('servicio.status', 'status')
|
||||
.where('programa.idUsuario = :idUsuario', { idUsuario })
|
||||
.andWhere('usuario.usuario LIKE :numeroCuenta', {
|
||||
numeroCuenta: `%${numeroCuenta}%`,
|
||||
})
|
||||
.andWhere('usuario.nombre LIKE :nombre', { nombre: `%${nombre}%` });
|
||||
|
||||
// 3️⃣ Filtro de estatus
|
||||
if (idStatus) {
|
||||
query.andWhere('status.idStatus = :idStatus', { idStatus });
|
||||
} else {
|
||||
query.andWhere('status.idStatus != :status', { status: 10 });
|
||||
}
|
||||
|
||||
// 4️⃣ Orden, paginación y selección de campos
|
||||
query
|
||||
.select([
|
||||
'servicio.idServicio',
|
||||
'servicio.fechaInicio',
|
||||
'servicio.fechaFin',
|
||||
'servicio.cartaTermino',
|
||||
'servicio.createdAt',
|
||||
'servicio.idCuestionarioPrograma',
|
||||
'servicio.idCuestionarioPrograma2',
|
||||
'usuario.idUsuario',
|
||||
'usuario.usuario',
|
||||
'usuario.nombre',
|
||||
'carrera.idCarrera',
|
||||
'carrera.carrera',
|
||||
'status.idStatus',
|
||||
'status.status',
|
||||
])
|
||||
.orderBy('servicio.updatedAt', 'DESC')
|
||||
.skip(25 * (pagina - 1))
|
||||
.take(25);
|
||||
|
||||
// 5️⃣ Ejecutar y obtener datos + total
|
||||
const [rows, count] = await query.getManyAndCount();
|
||||
|
||||
// 6️⃣ Retornar resultado en el mismo formato que antes
|
||||
return { count, serviciosResponsable: rows };
|
||||
}
|
||||
|
||||
async update(
|
||||
body: UpdateServicioDto,
|
||||
files: Record<string, Express.Multer.File[]>,
|
||||
) {
|
||||
const idServicio = body.idServicio;
|
||||
|
||||
const servicio = await this.servicioRepo.findOne({ where: { idServicio } });
|
||||
if (!servicio)
|
||||
throw new NotFoundException(
|
||||
'Este Servicio Social no existe en la base de datos.',
|
||||
);
|
||||
|
||||
let dataUpdate: Partial<Servicio> = {};
|
||||
|
||||
// ---- 📁 Subida de archivos a Drive ----
|
||||
try {
|
||||
if (files?.['cartaAceptacion']?.[0]?.filename) {
|
||||
{
|
||||
const result = await this.driveService.uploadFile(
|
||||
`./server/uploads/${files['cartaAceptacion'][0].filename}`,
|
||||
`Carta_Aceptacion.pdf`,
|
||||
'application/pdf',
|
||||
servicio.carpeta,
|
||||
);
|
||||
dataUpdate.cartaAceptacion = result === null ? undefined : result;
|
||||
}
|
||||
}
|
||||
} catch (err) {}
|
||||
|
||||
try {
|
||||
if (files?.['cartaTermino']?.[0]?.filename) {
|
||||
{
|
||||
const result = await this.driveService.uploadFile(
|
||||
`./server/uploads/${files['cartaTermino'][0].filename}`,
|
||||
`Carta_Termino.pdf`,
|
||||
'application/pdf',
|
||||
servicio.carpeta,
|
||||
);
|
||||
dataUpdate.cartaTermino = result === null ? undefined : result;
|
||||
}
|
||||
}
|
||||
} catch (err) {}
|
||||
|
||||
try {
|
||||
if (files?.['informeGlobal']?.[0]?.filename) {
|
||||
const result = await this.driveService.uploadFile(
|
||||
`./server/uploads/${files['informeGlobal'][0].filename}`,
|
||||
`Informe_Global.pdf`,
|
||||
'application/pdf',
|
||||
servicio.carpeta,
|
||||
);
|
||||
dataUpdate.informeGlobal = result === null ? undefined : result;
|
||||
}
|
||||
} catch (err) {}
|
||||
|
||||
// ---- 📆 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,
|
||||
'dirección',
|
||||
false,
|
||||
200,
|
||||
);
|
||||
if (body.telefono)
|
||||
dataUpdate.telefono = this.validacionService.validarNumero(
|
||||
body.telefono,
|
||||
'teléfono',
|
||||
true,
|
||||
15,
|
||||
);
|
||||
|
||||
if (this.validacionService.validarObjetoVacio(dataUpdate)) {
|
||||
throw new BadRequestException(
|
||||
'No se envió nada para actualizar este Servicio Social.',
|
||||
);
|
||||
}
|
||||
|
||||
// ---- 🧱 Actualización en la base ----
|
||||
await this.servicioRepo
|
||||
.createQueryBuilder()
|
||||
.update(Servicio)
|
||||
.set(dataUpdate)
|
||||
.where('idServicio = :idServicio', { idServicio })
|
||||
.execute();
|
||||
|
||||
// ---- ✅ Validar si se requiere "pre-término" ----
|
||||
if (dataUpdate.cartaTermino || dataUpdate.informeGlobal) {
|
||||
await this.validacionService.validarPreTermino(idServicio);
|
||||
}
|
||||
|
||||
return {
|
||||
message: 'Se guardaron correctamente los cambios de este servicio.',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user