organización de endpoints
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
const validar = require('../../helper/validar');
|
||||
const { validarId } = require('../../helper/validar');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
const CasoEspecial = require(`${dbPath}/CasoEspecial`);
|
||||
@@ -7,7 +7,7 @@ const TipoUsuario = require(`${dbPath}/TipoUsuario`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const admin = async (body) => {
|
||||
const idCasoEspecial = validar.validarId(body.idCasoEspecial);
|
||||
const idCasoEspecial = validarId(body.idCasoEspecial);
|
||||
|
||||
return CasoEspecial.findOne({
|
||||
where: { idCasoEspecial },
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
const validar = require('../../helper/validar');
|
||||
const gmail = require('../../helper/gmail');
|
||||
const correos = require('../../helper/correos');
|
||||
const helperPath = '../../helper';
|
||||
const correos = require(`${helperPath}/correos`);
|
||||
const gmail = require(`${helperPath}/gmail`);
|
||||
const { validarId } = require(`${helperPath}/validar`);
|
||||
const dbPath = '../../db/tablas';
|
||||
const CasoEspecial = require(`${dbPath}/CasoEspecial`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const liberacion = async (body) => {
|
||||
const idCasoEspecial = validar.validarId(body.idCasoEspecial);
|
||||
const idCasoEspecial = validarId(body.idCasoEspecial);
|
||||
let update = {};
|
||||
|
||||
return CasoEspecial.findOne({
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const validar = require('../../helper/validar');
|
||||
const drive = require('../../helper/drive');
|
||||
const helperPath = '../../helper';
|
||||
const drive = require(`${helperPath}/drive`);
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const dbPath = '../../db/tablas';
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
const CasoEspecial = require(`${dbPath}/CasoEspecial`);
|
||||
|
||||
@@ -41,7 +41,7 @@ const update = async (body) => {
|
||||
'El texto motivo.',
|
||||
1
|
||||
);
|
||||
if (validar.isObjectEmpty(dataUpdate))
|
||||
if (validar.validarObjetoVacio(dataUpdate))
|
||||
throw new Error(
|
||||
'No se envio nada para actualizar este Caso Especial.'
|
||||
);
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
const fs = require('fs');
|
||||
const { convertArrayToCSV } = require('convert-array-to-csv');
|
||||
const { Op } = require('sequelize');
|
||||
const validar = require('../../helper/validar');
|
||||
const helperPath = '../../helper';
|
||||
const helper = require(`${helperPath}/helper`);
|
||||
const { validarNumero } = require(`${helperPath}/validar`);
|
||||
const dbPath = '../../db/tablas';
|
||||
const CuestionarioAlumno = require(`${dbPath}/CuestionarioAlumno`);
|
||||
const Programa = require(`${dbPath}/Programa`);
|
||||
@@ -9,7 +10,7 @@ const Servicio = require(`${dbPath}/Servicio`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const get = async (body) => {
|
||||
const year = validar.validarNumero(body.year, 4);
|
||||
const year = validarNumero(body.year, 4);
|
||||
const path = `server/uploads/${year}_cuestionario_alumno.csv`;
|
||||
const data = [];
|
||||
|
||||
@@ -67,10 +68,10 @@ const get = async (body) => {
|
||||
p30: res[i].CuestionarioAlumno.p30,
|
||||
createdAt: res[i].CuestionarioAlumno.createdAt,
|
||||
});
|
||||
await validar.eliminarArchivo(path).catch((err) => {
|
||||
await helper.eliminarArchivo(path).catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
return validar.crearArchivo(path, convertArrayToCSV(data));
|
||||
return helper.crearArchivo(path, convertArrayToCSV(data));
|
||||
})
|
||||
.then((res) => {
|
||||
return path;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
const fs = require('fs');
|
||||
const { convertArrayToCSV } = require('convert-array-to-csv');
|
||||
const { Op } = require('sequelize');
|
||||
const validar = require('../../helper/validar');
|
||||
const helperPath = '../../helper';
|
||||
const helper = require(`${helperPath}/helper`);
|
||||
const { validarNumero } = require(`${helperPath}/validar`);
|
||||
const dbPath = '../../db/tablas';
|
||||
const CuestionarioPrograma = require(`${dbPath}/CuestionarioPrograma`);
|
||||
const Servicio = require(`${dbPath}/Servicio`);
|
||||
@@ -9,7 +11,7 @@ const Programa = require(`${dbPath}/Programa`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const get = async (body) => {
|
||||
const year = validar.validarNumero(body.year, 4);
|
||||
const year = validarNumero(body.year, 4);
|
||||
const path = `server/uploads/${year}_cuestionario_programa.csv`;
|
||||
const data = [];
|
||||
|
||||
@@ -43,10 +45,10 @@ const get = async (body) => {
|
||||
p7: res[i].CuestionarioPrograma.p7,
|
||||
createdAt: res[i].CuestionarioPrograma.createdAt,
|
||||
});
|
||||
await validar.eliminarArchivo(path).catch((err) => {
|
||||
await helper.eliminarArchivo(path).catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
return validar.crearArchivo(path, convertArrayToCSV(data));
|
||||
return helper.crearArchivo(path, convertArrayToCSV(data));
|
||||
})
|
||||
.then((res) => {
|
||||
return path;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
const fs = require('fs');
|
||||
const moment = require('moment');
|
||||
const csv = require('csvtojson');
|
||||
const moment = require('moment');
|
||||
const helperPath = '../../helper';
|
||||
const gmail = require(`${helperPath}/gmail`);
|
||||
const correos = require(`${helperPath}/correos`);
|
||||
const encriptar = require(`${helperPath}/encriptar`);
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const gmail = require(`${helperPath}/gmail`);
|
||||
const { validarCorreo } = require(`${helperPath}/validar`);
|
||||
const dbPath = '../../db/tablas';
|
||||
const Programa = require(`${dbPath}/Programa`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
@@ -34,7 +34,7 @@ const cargaMasiva = async (file) => {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
validar.validarCorreo(programas[i].correo);
|
||||
validarCorreo(programas[i].correo);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
mensaje += 'Esta linea contiene un correo no valido.\n\n';
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
const validar = require('../../helper/validar');
|
||||
const { validarId } = require('../../helper/validar');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Programa = require(`${dbPath}/Programa`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const programasAdmin = async (body) => {
|
||||
const idUsuario = validar.validarId(body.idUsuario);
|
||||
const idUsuario = validarId(body.idUsuario);
|
||||
|
||||
return Usuario.findOne({
|
||||
where: { idUsuario },
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
const validar = require('../../helper/validar');
|
||||
const { validarId } = require('../../helper/validar');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Programa = require(`${dbPath}/Programa`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const programasResponsable = async (body) => {
|
||||
const idUsuario = validar.validarId(body.idUsuario);
|
||||
const idUsuario = validarId(body.idUsuario);
|
||||
|
||||
return Usuario.findOne({
|
||||
where: { idUsuario },
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const validar = require('../../helper/validar');
|
||||
const { validarId } = require('../../helper/validar');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
const Programa = require(`${dbPath}/Programa`);
|
||||
@@ -8,7 +8,7 @@ const TipoUsuario = require(`${dbPath}/TipoUsuario`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const admin = async (body) => {
|
||||
const idServicio = validar.validarId(body.idServicio);
|
||||
const idServicio = validarId(body.idServicio);
|
||||
|
||||
return Servicio.findOne({
|
||||
where: { idServicio },
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const { Op } = require('sequelize');
|
||||
const validar = require('../../helper/validar');
|
||||
const { validarId } = require('../../helper/validar');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
const Programa = require(`${dbPath}/Programa`);
|
||||
@@ -8,7 +8,7 @@ const Status = require(`${dbPath}/Status`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const alumno = async (body) => {
|
||||
let idUsuario = validar.validarId(body.idUsuario);
|
||||
let idUsuario = validarId(body.idUsuario);
|
||||
|
||||
return Usuario.findOne({ where: { idUsuario } })
|
||||
.then((res) => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const helperPath = '../../helper';
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const gmail = require(`${helperPath}/gmail`);
|
||||
const correos = require(`${helperPath}/correos`);
|
||||
const gmail = require(`${helperPath}/gmail`);
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const dbPath = '../../db/tablas';
|
||||
const Programa = require(`${dbPath}/Programa`);
|
||||
const Servicio = require(`${dbPath}/Servicio`);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const helperPath = '../../helper';
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const drive = require(`${helperPath}/drive`);
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const Servicio = require('../../db/tablas/Servicio');
|
||||
|
||||
const cartaTermino = async (body, file) => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const helperPath = '../../helper';
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const drive = require(`${helperPath}/drive`);
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const Servicio = require('../../db/tablas/Servicio');
|
||||
|
||||
const cartaTermino = async (body, file) => {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
const fs = require('fs');
|
||||
const moment = require('moment');
|
||||
const { convertArrayToCSV } = require('convert-array-to-csv');
|
||||
const { Op } = require('sequelize');
|
||||
const validar = require('../../helper/validar');
|
||||
const helperPath = '../../helper';
|
||||
const helper = require(`${helperPath}/helper`);
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const dbPath = '../../db/tablas';
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
const Servicio = require(`${dbPath}/Servicio`);
|
||||
@@ -32,12 +33,12 @@ const gustavoBazPrada = async (body) => {
|
||||
nombre: res[i].Usuario.nombre,
|
||||
licenciatura: res[i].Carrera.carrera,
|
||||
correo: res[i].correo,
|
||||
fechaLiberacion: validar.crearDDMMAAAA(res[i].fechaLiberacion),
|
||||
fechaLiberacion: helper.crearDDMMAAAA(res[i].fechaLiberacion),
|
||||
});
|
||||
await validar.eliminarArchivo(path).catch((err) => {
|
||||
await helper.eliminarArchivo(path).catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
return validar.crearArchivo(path, convertArrayToCSV(data));
|
||||
return helper.crearArchivo(path, convertArrayToCSV(data));
|
||||
})
|
||||
.then((res) => {
|
||||
return path;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const helperPath = '../../helper';
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const drive = require(`${helperPath}/drive`);
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const Servicio = require('../../db/tablas/Servicio');
|
||||
|
||||
const informeGlobal = async (body, file) => {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
const moment = require('moment');
|
||||
const helperPath = '../../helper';
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const gmail = require(`${helperPath}/gmail`);
|
||||
const correos = require(`${helperPath}/correos`);
|
||||
const gmail = require(`${helperPath}/gmail`);
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const dbPath = '../../db/tablas';
|
||||
const Programa = require(`${dbPath}/Programa`);
|
||||
const Servicio = require(`${dbPath}/Servicio`);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const { Op } = require('sequelize');
|
||||
const helperPath = '../../helper';
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const drive = require(`${helperPath}/drive`);
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const dbPath = '../../db/tablas';
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
const Programa = require(`${dbPath}/Programa`);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const helperPath = '../../helper';
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const gmail = require(`${helperPath}/gmail`);
|
||||
const correos = require(`${helperPath}/correos`);
|
||||
const gmail = require(`${helperPath}/gmail`);
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const dbPath = '../../db/tablas';
|
||||
const Programa = require(`${dbPath}/Programa`);
|
||||
const Servicio = require(`${dbPath}/Servicio`);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const helperPath = '../../helper';
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const gmail = require(`${helperPath}/gmail`);
|
||||
const correos = require(`${helperPath}/correos`);
|
||||
const gmail = require(`${helperPath}/gmail`);
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const dbPath = '../../db/tablas';
|
||||
const Programa = require(`${dbPath}/Programa`);
|
||||
const Servicio = require(`${dbPath}/Servicio`);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const helperPath = '../../helper';
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const gmail = require(`${helperPath}/gmail`);
|
||||
const correos = require(`${helperPath}/correos`);
|
||||
const gmail = require(`${helperPath}/gmail`);
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const dbPath = '../../db/tablas';
|
||||
const Programa = require(`${dbPath}/Programa`);
|
||||
const Servicio = require(`${dbPath}/Servicio`);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
const helperPath = '../../helper';
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const correos = require(`${helperPath}/correos`);
|
||||
const encriptar = require(`${helperPath}/encriptar`);
|
||||
const gmail = require(`${helperPath}/gmail`);
|
||||
const correos = require(`${helperPath}/correos`);
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const dbPath = '../../db/tablas';
|
||||
const Servicio = require(`${dbPath}/Servicio`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const helperPath = '../../helper';
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const gmail = require(`${helperPath}/gmail`);
|
||||
const correos = require(`${helperPath}/correos`);
|
||||
const gmail = require(`${helperPath}/gmail`);
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const dbPath = '../../db/tablas';
|
||||
const Programa = require(`${dbPath}/Programa`);
|
||||
const Servicio = require(`${dbPath}/Servicio`);
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
const fs = require('fs');
|
||||
const { convertArrayToCSV } = require('convert-array-to-csv');
|
||||
const { Op } = require('sequelize');
|
||||
const validar = require('../../helper/validar');
|
||||
const helperPath = '../../helper';
|
||||
const helper = require(`${helperPath}/helper`);
|
||||
const { validarFecha } = require(`${helperPath}/validar`);
|
||||
const dbPath = '../../db/tablas';
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
const Programa = require(`${dbPath}/Programa`);
|
||||
@@ -10,8 +11,8 @@ const Status = require(`${dbPath}/Status`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const reporte = async (body) => {
|
||||
const inicio = validar.validarFecha(body.inicio);
|
||||
const fin = validar.validarFecha(body.fin);
|
||||
const inicio = validarFecha(body.inicio);
|
||||
const fin = validarFecha(body.fin);
|
||||
const path = `server/uploads/reporte.csv`;
|
||||
const data = [];
|
||||
|
||||
@@ -37,9 +38,9 @@ const reporte = async (body) => {
|
||||
nombre: res[i].Usuario.nombre,
|
||||
licenciatura: res[i].Carrera.carrera,
|
||||
correo: res[i].correo,
|
||||
fechaInicio: validar.crearDDMMAAAA(res[i].fechaInicio),
|
||||
fechaFin: validar.crearDDMMAAAA(res[i].fechaFin),
|
||||
fechaLiberacion: validar.crearDDMMAAAA(res[i].fechaLiberacion),
|
||||
fechaInicio: helper.crearDDMMAAAA(res[i].fechaInicio),
|
||||
fechaFin: helper.crearDDMMAAAA(res[i].fechaFin),
|
||||
fechaLiberacion: helper.crearDDMMAAAA(res[i].fechaLiberacion),
|
||||
institucion: res[i].Programa.institucion,
|
||||
dependencia: res[i].Programa.dependencia,
|
||||
programa: res[i].Programa.programa,
|
||||
@@ -47,10 +48,10 @@ const reporte = async (body) => {
|
||||
clave: res[i].Programa.clavePrograma,
|
||||
status: res[i].Status.status,
|
||||
});
|
||||
await validar.eliminarArchivo(path).catch((err) => {
|
||||
await helper.eliminarArchivo(path).catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
return validar.crearArchivo(path, convertArrayToCSV(data));
|
||||
return helper.crearArchivo(path, convertArrayToCSV(data));
|
||||
})
|
||||
.then((res) => {
|
||||
return path;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const helperPath = '../../helper';
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const drive = require(`${helperPath}/drive`);
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const Servicio = require('../../db/tablas/Servicio');
|
||||
|
||||
const update = async (body, files) => {
|
||||
@@ -52,7 +52,7 @@ const update = async (body, files) => {
|
||||
);
|
||||
if (body.telefono)
|
||||
dataUpdate.telefono = validar.validarNumero(body.telefono, 15);
|
||||
if (validar.isObjectEmpty(dataUpdate))
|
||||
if (validar.validarObjetoVacio(dataUpdate))
|
||||
throw new Error(
|
||||
'No se envio nada para actualizar este Servicio Social'
|
||||
);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
require('../../config/config');
|
||||
const axios = require('axios');
|
||||
const validar = require('../../helper/validar');
|
||||
const { validarNumeroCuenta } = require('../../helper/validar');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
|
||||
const escolares = async (body) => {
|
||||
const numeroCuenta = validar.validarNumeroCuenta(body.numeroCuenta);
|
||||
const numeroCuenta = validarNumeroCuenta(body.numeroCuenta);
|
||||
let alumno;
|
||||
|
||||
return axios({
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const helperPath = '../../helper';
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const { validarId } = require(`${helperPath}/validar`);
|
||||
const gmail = require(`${helperPath}/gmail`);
|
||||
const correos = require(`${helperPath}/correos`);
|
||||
const encriptar = require(`${helperPath}/encriptar`);
|
||||
@@ -8,7 +8,7 @@ const Usuario = require(`${dbPath}/Usuario`);
|
||||
const Servicio = require(`${dbPath}/Servicio`);
|
||||
|
||||
const newPasswordAlumno = async (body) => {
|
||||
const idServicio = validar.validarId(body.idServicio);
|
||||
const idServicio = validarId(body.idServicio);
|
||||
const password = encriptar.generarPassword();
|
||||
let idUsuario;
|
||||
let correo = {};
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
const helperPath = '../../helper';
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const { validarId } = require(`${helperPath}/validar`);
|
||||
const gmail = require(`${helperPath}/gmail`);
|
||||
const correos = require(`${helperPath}/correos`);
|
||||
const encriptar = require(`${helperPath}/encriptar`);
|
||||
const Usuario = require('../../db/tablas/Usuario');
|
||||
|
||||
const newPasswordResponsable = async (body) => {
|
||||
const idUsuario = await validar.validarId(body.idUsuario);
|
||||
const idUsuario = await validarId(body.idUsuario);
|
||||
const password = encriptar.generarPassword();
|
||||
let correo = {};
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ const responsableUpdate = async (body) => {
|
||||
if (body.nombre)
|
||||
dataUpdate.nombre = validar.validarTexto(body.nombre, 'el nombre', 70);
|
||||
|
||||
if (validar.isObjectEmpty(dataUpdate))
|
||||
if (validar.validarObjetoVacio(dataUpdate))
|
||||
throw new Error('No se a envio nada para actualizar.');
|
||||
return Usuario.update(dataUpdate, { where: { idUsuario } });
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user