listo
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
const validar = require('../../helper/validar');
|
||||
const CasoEspecial = require('../../db/tablas/CasoEspecial');
|
||||
const Usuario = require('../../db/tablas/Usuario');
|
||||
const TipoUsuario = require('../../db/tablas/TipoUsuario');
|
||||
const Carrera = require('../../db/tablas/Carrera');
|
||||
const Status = require('../../db/tablas/Status');
|
||||
|
||||
const admin = async (body) => {
|
||||
const idCasoEspecial = validar.validarId(body.idCasoEspecial);
|
||||
|
||||
return CasoEspecial.findOne({
|
||||
where: { idCasoEspecial },
|
||||
include: [
|
||||
{ model: Usuario, include: [{ model: TipoUsuario }] },
|
||||
{ model: Carrera },
|
||||
{ model: Status },
|
||||
],
|
||||
}).then((res) => {
|
||||
if (!res) throw new Error('No existe este Caso Especial.');
|
||||
delete res.dataValues.Usuario.dataValues.password;
|
||||
delete res.dataValues.idUsuario;
|
||||
delete res.dataValues.idCarrera;
|
||||
delete res.dataValues.idStatus;
|
||||
return res;
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = admin;
|
||||
@@ -1,33 +1,34 @@
|
||||
const validar = require('../../helper/validar');
|
||||
const gmail = require('../../helper/gmail');
|
||||
const correos = require('../../helper/correos');
|
||||
const Servicio = require('../../db/tablas/Servicio');
|
||||
const CasoEspecial = require('../../db/tablas/CasoEspecial');
|
||||
const Usuario = require('../../db/tablas/Usuario');
|
||||
|
||||
const liberacion = async (body) => {
|
||||
const idServicio = validar.validarId(body.idServicio);
|
||||
const idCasoEspecial = validar.validarId(body.idCasoEspecial);
|
||||
let update = {};
|
||||
|
||||
return Servicio.findOne({
|
||||
where: { idServicio },
|
||||
return CasoEspecial.findOne({
|
||||
where: { idCasoEspecial },
|
||||
include: [{ model: Usuario }],
|
||||
})
|
||||
.then(async (res) => {
|
||||
if (!res) throw new Error('No existe este Servicio Social.');
|
||||
if (!res) throw new Error('No existe este Caso Especial.');
|
||||
switch (res.idStatus) {
|
||||
case 11:
|
||||
case 12:
|
||||
let correo = correos.terminoValidado(res.Usuario.nombre);
|
||||
|
||||
if (res.idStatus === 11) update.idStatus = 13;
|
||||
else update.idStatus = 14;
|
||||
return gmail(correo.subject, res.correo, correo.msj);
|
||||
case 6:
|
||||
throw new Error(
|
||||
'Este Servicio Social ya se encuentra en Liberación.'
|
||||
);
|
||||
throw new Error('Este Caso Especial ya se encuentra en Liberación.');
|
||||
default:
|
||||
throw new Error('Id status no valido.');
|
||||
}
|
||||
})
|
||||
.then((res) => Servicio.update({ idStatus: 6 }, { where: { idServicio } }))
|
||||
.then((res) => CasoEspecial.update(update, { where: { idCasoEspecial } }))
|
||||
.then((res) => ({
|
||||
message:
|
||||
'Se cambio de estatus correctamente y se envio un correo al alumno informandole de su liberación.',
|
||||
|
||||
@@ -6,8 +6,6 @@ const Carrera = require('../../db/tablas/Carrera');
|
||||
const validar = require('../../helper/validar');
|
||||
|
||||
const nuevo = async (body, file) => {
|
||||
console.log('Hola');
|
||||
|
||||
const idUsuario = validar.validarId(body.idUsuario);
|
||||
const idCarrera = validar.validarId(body.idCarrera);
|
||||
const idStatus = validar.validarId(body.idStatus);
|
||||
@@ -50,7 +48,7 @@ const nuevo = async (body, file) => {
|
||||
});
|
||||
})
|
||||
.then(async (res) => {
|
||||
if (res) throw new Error('Este alumno ya tienen un Servicio Especial.');
|
||||
if (res) throw new Error('Este alumno ya tienen un Caso Especial.');
|
||||
return drive.folder(numeroCuenta);
|
||||
})
|
||||
.then((res) => {
|
||||
@@ -81,7 +79,7 @@ const nuevo = async (body, file) => {
|
||||
})
|
||||
)
|
||||
.then((res) => ({
|
||||
message: `Se ha registro el Servicio Especial correctamente.`,
|
||||
message: `Se ha registro el Caso Especial correctamente.`,
|
||||
}));
|
||||
};
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ const serviciosEspeciales = async (body) => {
|
||||
const pagina = validar.validarId(body.pagina);
|
||||
const where = body.idStatus
|
||||
? { idStatus: validar.validarId(body.idStatus) }
|
||||
: { [Op.or]: [{ idStatus: 6 }, { idStatus: { [Op.gt]: 10 } }] };
|
||||
: { idStatus: { [Op.gt]: 10 } };
|
||||
const nombre = body.nombre
|
||||
? validar.validarTexto(body.nombre, 'El nombre', 60)
|
||||
: '';
|
||||
@@ -36,7 +36,7 @@ const serviciosEspeciales = async (body) => {
|
||||
}).then((res) => {
|
||||
for (let i = pagina * 25 - 25; i < res.length && i < pagina * 25; i++)
|
||||
data.push({
|
||||
idServicio: res[i].idServicio,
|
||||
idCasoEspecial: res[i].idCasoEspecial,
|
||||
createdAt: res[i].createdAt,
|
||||
Usuario: {
|
||||
idUsuario: res[i].Usuario.idUsuario,
|
||||
|
||||
Reference in New Issue
Block a user