fechas en db
This commit is contained in:
@@ -35,6 +35,8 @@ const admin = (body) => {
|
||||
programaInterno: res.programaInterno,
|
||||
profesor: res.profesor,
|
||||
vistoBuenoAcatlan: res.vistoBuenoAcatlan,
|
||||
createdAt: res.createdAt,
|
||||
updatedAt: res.updatedAt,
|
||||
idCuestionarioAlumno: res.idCuestionarioAlumno,
|
||||
idCuestionarioPrograma: res.idCuestionarioPrograma,
|
||||
Usuario: {
|
||||
|
||||
@@ -41,6 +41,8 @@ const alumno = async (body) => {
|
||||
programaInterno: res.programaInterno,
|
||||
profesor: res.profesor,
|
||||
vistoBuenoAcatlan: res.vistoBuenoAcatlan,
|
||||
createdAt: res.createdAt,
|
||||
updatedAt: res.updatedAt,
|
||||
idCuestionarioAlumno: res.idCuestionarioAlumno,
|
||||
idCuestionarioPrograma: res.idCuestionarioPrograma,
|
||||
Carrera: {
|
||||
|
||||
@@ -12,7 +12,7 @@ const cancelar = async (body) => {
|
||||
return Servicio.update({ idStatus: 10 }, { where: { idServicio } });
|
||||
})
|
||||
.then((res) => {
|
||||
return { message: 'Se cancelo correctamente el servicio.' };
|
||||
return { message: 'Se cancelo correctamente este Servicio Social.' };
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -10,13 +10,21 @@ const nuevo = async (body, file) => {
|
||||
let idUsuario = validar.validarId(body.idUsuario);
|
||||
let idPrograma = validar.validarId(body.idPrograma);
|
||||
let idCarrera = validar.validarId(body.idCarrera);
|
||||
let numeroCuenta = validar.validarNumeroCuenta(body.numeroCuenta);
|
||||
let creditos = validar.validarNumero(body.creditos);
|
||||
let correo = validar.validarCorreo(body.correo);
|
||||
let fechaInicio = validar.validarFecha(body.fechaInicio);
|
||||
let fechaFin = validar.validarFecha(body.fechaFin);
|
||||
let path = `./server/uploads/${validar.validar(file, 'El archivo')}`;
|
||||
let carpeta = '';
|
||||
let cartaAceptacion = '';
|
||||
|
||||
return Usuario.findOne({
|
||||
where: { idUsuario },
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('Este alumno no existe en la db.');
|
||||
if (res.idTipoUsuario === 3)
|
||||
if (res.idTipoUsuario !== 3)
|
||||
throw new Error('Este usuario no es de tipo Alumno.');
|
||||
return Programa.findOne({ where: { idPrograma } });
|
||||
})
|
||||
@@ -33,21 +41,19 @@ const nuevo = async (body, file) => {
|
||||
.then(async (res) => {
|
||||
if (res)
|
||||
throw new Error('Este alumno ya tienen un Servicio Social activo.');
|
||||
|
||||
let numeroCuenta = validar.validarNumeroCuenta(body.numeroCuenta);
|
||||
let creditos = validar.validarNumero(body.creditos);
|
||||
let correo = validar.validarCorreo(body.correo);
|
||||
let fechaInicio = validar.validarFecha(body.fechaInicio);
|
||||
let fechaFin = validar.validarFecha(body.fechaFin);
|
||||
let carpeta = await drive.folder(numeroCuenta);
|
||||
let path = `./server/uploads/${validar.validar(file, 'El archivo')}`;
|
||||
let cartaAceptacion = await drive.uploadFile(
|
||||
return drive.folder(numeroCuenta);
|
||||
})
|
||||
.then((res) => {
|
||||
carpeta = res;
|
||||
return drive.uploadFile(
|
||||
path,
|
||||
`Carta_Aceptacion.pdf`,
|
||||
'application/pdf',
|
||||
carpeta
|
||||
);
|
||||
|
||||
})
|
||||
.then((res) => {
|
||||
cartaAceptacion = res;
|
||||
return Servicio.create({
|
||||
idUsuario,
|
||||
idPrograma,
|
||||
|
||||
@@ -68,7 +68,7 @@ const registroValidado = async (body) => {
|
||||
.then((res) => {
|
||||
return {
|
||||
message:
|
||||
'Se cambio de estatus correctamente y se envio un correo al alumno y al responsable de programa.',
|
||||
'Haz terminado el registro de tu Servicio Social correctamente.',
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -148,7 +148,9 @@ CuestionarioAlumno.init(
|
||||
sequelize,
|
||||
modelName: 'CuestionarioAlumno',
|
||||
tableName: 'cuestionario_alumno',
|
||||
timestamps: false,
|
||||
timestamps: true,
|
||||
createdAt: true,
|
||||
updatedAt: false,
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -48,7 +48,9 @@ CuestionarioPrograma.init(
|
||||
sequelize,
|
||||
modelName: 'CuestionarioPrograma',
|
||||
tableName: 'cuestionario_programa',
|
||||
timestamps: false,
|
||||
timestamps: true,
|
||||
createdAt: true,
|
||||
updatedAt: false,
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ Servicio.init(
|
||||
sequelize,
|
||||
modelName: 'Servicio',
|
||||
tableName: 'servicio',
|
||||
timestamps: false,
|
||||
timestamps: true,
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
const fs = require('fs');
|
||||
const express = require('express');
|
||||
const multer = require('multer');
|
||||
const app = express();
|
||||
@@ -20,6 +21,8 @@ app.post(`${route}/nuevo`, upload.single('cartaAceptacion'), (req, res) => {
|
||||
res.status(201).json(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
if (req.file.filename)
|
||||
fs.unlinkSync(`./server/uploads/${req.file.filename}`);
|
||||
res.status(400).json({ message: err.message });
|
||||
});
|
||||
});
|
||||
@@ -100,6 +103,8 @@ app.put(`${route}/carta_termino`, upload.single('cartaTermino'), (req, res) => {
|
||||
res.status(200).json(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
if (req.file.filename)
|
||||
fs.unlinkSync(`./server/uploads/${req.file.filename}`);
|
||||
res.status(400).json({ message: err.message });
|
||||
});
|
||||
});
|
||||
@@ -113,6 +118,8 @@ app.put(
|
||||
res.status(200).json(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
if (req.file.filename)
|
||||
fs.unlinkSync(`./server/uploads/${req.file.filename}`);
|
||||
res.status(400).json({ message: err.message });
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user