Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 79c883ad79 | |||
| faa8889019 | |||
| fc7ec840a4 | |||
| 79f82db59e | |||
| f8d17c8f27 | |||
| d124dfa02f | |||
| babe7e56b2 | |||
| 606c4369af | |||
| 8a0bfb7801 | |||
| 081434d3fc | |||
| a326add0ab |
@@ -1,10 +1,11 @@
|
|||||||
const Invitado = require('../../db/tablas/Invitado');
|
const Invitado = require('../../db/tablas/Invitado');
|
||||||
const Profesor = require('../../db/tablas/Profesor');
|
const Profesor = require('../../db/tablas/Profesor');
|
||||||
const Premiacion = require('../../db/tablas/Premiacion');
|
const Premiacion = require('../../db/tablas/Premiacion');
|
||||||
|
const ProfesorPremiacion = require('../../db/tablas/ProfesorPremiacion');
|
||||||
const validar = require('../../helper/validar');
|
const validar = require('../../helper/validar');
|
||||||
const { correo } = require('../../helper/correos');
|
const { correo } = require('../../helper/correos');
|
||||||
const gmail = require('../../helper/gmail');
|
const gmail = require('../../helper/gmail');
|
||||||
const ProfesorPremiacion = require('../../db/tablas/ProfesorPremiacion');
|
const moment = require('moment');
|
||||||
|
|
||||||
const infoInvitados = async (body) => {
|
const infoInvitados = async (body) => {
|
||||||
const idProfesor = validar.validarNumeroEntero(body.idProfesor, 'idProfesor');
|
const idProfesor = validar.validarNumeroEntero(body.idProfesor, 'idProfesor');
|
||||||
@@ -37,7 +38,7 @@ const infoInvitados = async (body) => {
|
|||||||
'No existe ningún profesor con este id en esta premiación.'
|
'No existe ningún profesor con este id en esta premiación.'
|
||||||
);
|
);
|
||||||
if (profPrem.numeroInvitados)
|
if (profPrem.numeroInvitados)
|
||||||
throw new Error('A este profesor ya se le han guardado sus invitados.');
|
throw new Error('Este profesor ya registró invitados en otro momento.');
|
||||||
profPrem.update({ numeroInvitados: numeroInvitados });
|
profPrem.update({ numeroInvitados: numeroInvitados });
|
||||||
|
|
||||||
const respuesta = [];
|
const respuesta = [];
|
||||||
@@ -64,19 +65,19 @@ const infoInvitados = async (body) => {
|
|||||||
throw new Error('No se ha podido ingresar los datos del invitado');
|
throw new Error('No se ha podido ingresar los datos del invitado');
|
||||||
respuesta.push(res);
|
respuesta.push(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let fecha = moment(premiacion.fecha).format("DD-MM-YYYY")
|
||||||
const Mail = correo(
|
const Mail = correo(
|
||||||
profPrem.idProfesor,
|
profPrem.idProfesor,
|
||||||
profPrem.idPremiacion,
|
profPrem.idPremiacion,
|
||||||
premiacion.premiacion,
|
premiacion.premiacion,
|
||||||
premiacion.fecha,
|
fecha,
|
||||||
premiacion.hora
|
premiacion.hora
|
||||||
);
|
);
|
||||||
|
|
||||||
const dataProf = await Profesor.findOne({ where: idProfesor });
|
const dataProf = await Profesor.findOne({ where: idProfesor });
|
||||||
gmail(
|
gmail(
|
||||||
Mail.subject,
|
Mail.subject,
|
||||||
// `jeremy@acatlan.unam.mx`,
|
|
||||||
`${dataProf.numeroTrabajador}@pcpuma.acatlan.unam.mx`,
|
`${dataProf.numeroTrabajador}@pcpuma.acatlan.unam.mx`,
|
||||||
Mail.message
|
Mail.message
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -24,7 +24,9 @@ const premiaciones = async (query) => {
|
|||||||
|
|
||||||
for (let i = 0; i < res.length; i++) {
|
for (let i = 0; i < res.length; i++) {
|
||||||
let resp = await Premiacion.findOne({ where: res[i].idPremiacion });
|
let resp = await Premiacion.findOne({ where: res[i].idPremiacion });
|
||||||
premiaciones[i] = resp.dataValues;
|
if(resp.dataValues.activa) {
|
||||||
|
premiaciones.push(resp.dataValues);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return premiaciones;
|
return premiaciones;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
const Profesor = require('../../db/tablas/Profesor');
|
||||||
|
const Premiacion = require('../../db/tablas/Premiacion');
|
||||||
|
const ProfesorPremiacion = require('../../db/tablas/ProfesorPremiacion');
|
||||||
|
const validar = require('../../helper/validar');
|
||||||
|
|
||||||
|
const yaRegistro = async (query) => {
|
||||||
|
console.log(query)
|
||||||
|
const idProfesor = validar.validarNumeroEntero(
|
||||||
|
query.idProfesor,
|
||||||
|
'idProfesor'
|
||||||
|
);
|
||||||
|
const idPremiacion = validar.validarNumeroEntero(
|
||||||
|
query.idPremiacion,
|
||||||
|
'idPremiacion'
|
||||||
|
);
|
||||||
|
|
||||||
|
return Profesor.findOne({ where: { idProfesor } }).then((res) => {
|
||||||
|
if (!res) throw new Error('Este profesor no existe.');
|
||||||
|
|
||||||
|
return Premiacion.findOne({ where: { idPremiacion } }).then((res) => {
|
||||||
|
if (!res) throw new Error('Esta premiacion no existe.');
|
||||||
|
|
||||||
|
return ProfesorPremiacion.findOne({
|
||||||
|
where: { idPremiacion, idProfesor },
|
||||||
|
}).then((res) => {
|
||||||
|
if (!res) throw new Error('Este profesor no tiene premiaciones.');
|
||||||
|
|
||||||
|
if (res.numeroInvitados) return true;
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = yaRegistro;
|
||||||
@@ -11,7 +11,7 @@ const login = async (body) => {
|
|||||||
true,
|
true,
|
||||||
30
|
30
|
||||||
);
|
);
|
||||||
const password = validar.validarAlfanumerico(
|
const password = validar.validacionBasicaStr(
|
||||||
body.password,
|
body.password,
|
||||||
'contraseña',
|
'contraseña',
|
||||||
false,
|
false,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ const login = async (body) => {
|
|||||||
true,
|
true,
|
||||||
30
|
30
|
||||||
);
|
);
|
||||||
const password = validar.validarAlfanumerico(
|
const password = validar.validacionBasicaStr(
|
||||||
body.password,
|
body.password,
|
||||||
'contraseña',
|
'contraseña',
|
||||||
false,
|
false,
|
||||||
|
|||||||
+17
-1
@@ -1,6 +1,6 @@
|
|||||||
require('../config/config');
|
require('../config/config');
|
||||||
|
const { encriptar } = require('../helper/encriptar');
|
||||||
const colors = require('colors');
|
const colors = require('colors');
|
||||||
// const encriptar = require('../helper/encriptar');
|
|
||||||
const TipoUsuario = require('./tablas/TipoUsuario');
|
const TipoUsuario = require('./tablas/TipoUsuario');
|
||||||
const Usuario = require('./tablas/Usuario');
|
const Usuario = require('./tablas/Usuario');
|
||||||
const Profesor = require('./tablas/Profesor');
|
const Profesor = require('./tablas/Profesor');
|
||||||
@@ -60,10 +60,26 @@ const dataTipoUsuario = async () => {
|
|||||||
await TipoUsuario.create({ tipoUsuario: data[i] });
|
await TipoUsuario.create({ tipoUsuario: data[i] });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const dataUsuarios = async () => {
|
||||||
|
let usuario = ['Admin', 'Operador1'];
|
||||||
|
let password = ['Pr3m10-Fa', 'M3dl-4tWn']
|
||||||
|
|
||||||
|
console.log('\nPaso 4) Instalando los usuarios.'.bold.blue);
|
||||||
|
for (let i = 0; i < usuario.length; i++) {
|
||||||
|
await Usuario.create({
|
||||||
|
usuario: usuario[i],
|
||||||
|
password: encriptar(password[i]),
|
||||||
|
idTipoUsuario: i+1,
|
||||||
|
});
|
||||||
|
console.log(`Se insertó el usuario ${usuario[i]}.`.magenta);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const exe = async () => {
|
const exe = async () => {
|
||||||
await drop();
|
await drop();
|
||||||
await sync();
|
await sync();
|
||||||
await dataTipoUsuario();
|
await dataTipoUsuario();
|
||||||
|
await dataUsuarios();
|
||||||
console.log(
|
console.log(
|
||||||
'\nSe ha instalado exitosamente la base de datos.\n'.underline.bold.green
|
'\nSe ha instalado exitosamente la base de datos.\n'.underline.bold.green
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ Premiacion.init(
|
|||||||
autoIncrement: true,
|
autoIncrement: true,
|
||||||
},
|
},
|
||||||
premiacion: {
|
premiacion: {
|
||||||
type: DataTypes.STRING(50),
|
type: DataTypes.STRING(70),
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
},
|
},
|
||||||
hora: {
|
hora: {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ Profesor.init(
|
|||||||
allowNull: false,
|
allowNull: false,
|
||||||
},
|
},
|
||||||
adscripcion: {
|
adscripcion: {
|
||||||
type: DataTypes.STRING(80),
|
type: DataTypes.STRING(200),
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
},
|
},
|
||||||
correo: {
|
correo: {
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ const caracterEspecial = (char) => {
|
|||||||
'/',
|
'/',
|
||||||
'#',
|
'#',
|
||||||
'%',
|
'%',
|
||||||
|
'@',
|
||||||
|
'$',
|
||||||
'\n',
|
'\n',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
const express = require('express');
|
const express = require('express');
|
||||||
const app = express();
|
const app = express();
|
||||||
// const { verificaToken } = require('../middleware/autentificacion');
|
const { verificaToken } = require('../middleware/autentificacion');
|
||||||
const route = '/invitado';
|
const route = '/invitado';
|
||||||
const controllerPath = '../controller/Invitado';
|
const controllerPath = '../controller/Invitado';
|
||||||
const get = require(`${controllerPath}/invitados`);
|
const get = require(`${controllerPath}/invitados`);
|
||||||
const infoInvitados = require(`${controllerPath}/infoInvitados`);
|
const infoInvitados = require(`${controllerPath}/infoInvitados`);
|
||||||
|
|
||||||
app.get(`${route}/get`, (req, res) => {
|
app.get(`${route}/get`, verificaToken, (req, res) => {
|
||||||
return get(req.query)
|
return get(req.query)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
res.status(200).json(data);
|
res.status(200).json(data);
|
||||||
@@ -16,7 +16,7 @@ app.get(`${route}/get`, (req, res) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post(`${route}/infoInvitados`, (req, res) => {
|
app.post(`${route}/infoInvitados`, verificaToken, (req, res) => {
|
||||||
return infoInvitados(req.body)
|
return infoInvitados(req.body)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
res.status(200).json(data);
|
res.status(200).json(data);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
const express = require('express');
|
const express = require('express');
|
||||||
const app = express();
|
const app = express();
|
||||||
// const { verificaToken } = require('../middleware/autentificacion');
|
const { verificaToken } = require('../middleware/autentificacion');
|
||||||
const route = '/premiacion';
|
const route = '/premiacion';
|
||||||
const controllerPath = '../controller/Premiacion';
|
const controllerPath = '../controller/Premiacion';
|
||||||
const get = require(`${controllerPath}/premiaciones`);
|
const get = require(`${controllerPath}/premiaciones`);
|
||||||
@@ -9,7 +9,7 @@ const editar = require(`${controllerPath}/editar`);
|
|||||||
const nueva = require(`${controllerPath}/nueva`);
|
const nueva = require(`${controllerPath}/nueva`);
|
||||||
const activarDesactivar = require(`${controllerPath}/activarDesactivar`);
|
const activarDesactivar = require(`${controllerPath}/activarDesactivar`);
|
||||||
|
|
||||||
app.get(`${route}/get`, (req, res) => {
|
app.get(`${route}/get`, verificaToken, (req, res) => {
|
||||||
return get()
|
return get()
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
res.status(200).json(data);
|
res.status(200).json(data);
|
||||||
@@ -19,7 +19,7 @@ app.get(`${route}/get`, (req, res) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get(`${route}/premiacionesPaginacion`, (req, res) => {
|
app.get(`${route}/premiacionesPaginacion`, verificaToken, (req, res) => {
|
||||||
return getPaginacion(req.query)
|
return getPaginacion(req.query)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
res.status(200).json(data);
|
res.status(200).json(data);
|
||||||
@@ -29,7 +29,7 @@ app.get(`${route}/premiacionesPaginacion`, (req, res) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post(`${route}/nueva`, (req, res) => {
|
app.post(`${route}/nueva`, verificaToken, (req, res) => {
|
||||||
return nueva(req.body)
|
return nueva(req.body)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
res.status(200).json(data);
|
res.status(200).json(data);
|
||||||
@@ -39,7 +39,7 @@ app.post(`${route}/nueva`, (req, res) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.put(`${route}/editar`, (req, res) => {
|
app.put(`${route}/editar`, verificaToken, (req, res) => {
|
||||||
return editar(req.body)
|
return editar(req.body)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
res.status(200).json(data);
|
res.status(200).json(data);
|
||||||
@@ -49,7 +49,7 @@ app.put(`${route}/editar`, (req, res) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.put(`${route}/activarDesactivar`, (req, res) => {
|
app.put(`${route}/activarDesactivar`, verificaToken, (req, res) => {
|
||||||
return activarDesactivar(req.body)
|
return activarDesactivar(req.body)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
res.status(200).json(data);
|
res.status(200).json(data);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ const express = require('express');
|
|||||||
const app = express();
|
const app = express();
|
||||||
const multer = require('multer');
|
const multer = require('multer');
|
||||||
const upload = multer({ dest: 'server/uploads' });
|
const upload = multer({ dest: 'server/uploads' });
|
||||||
// const { verificaToken } = require('../middleware/autentificacion');
|
const { verificaToken } = require('../middleware/autentificacion');
|
||||||
const route = '/profesor';
|
const route = '/profesor';
|
||||||
const controllerPath = '../controller/Profesor';
|
const controllerPath = '../controller/Profesor';
|
||||||
const login = require(`${controllerPath}/login`);
|
const login = require(`${controllerPath}/login`);
|
||||||
@@ -10,6 +10,7 @@ const entradaInvitado = require(`${controllerPath}/entradaInvitado`);
|
|||||||
const cargarDatos = require(`${controllerPath}/cargarDatos`);
|
const cargarDatos = require(`${controllerPath}/cargarDatos`);
|
||||||
const adscripciones = require(`${controllerPath}/adscripciones`);
|
const adscripciones = require(`${controllerPath}/adscripciones`);
|
||||||
const premiaciones = require(`${controllerPath}/premiaciones`);
|
const premiaciones = require(`${controllerPath}/premiaciones`);
|
||||||
|
const yaRegistro = require(`${controllerPath}/yaRegistro`);
|
||||||
|
|
||||||
app.post(`${route}/login`, (req, res) => {
|
app.post(`${route}/login`, (req, res) => {
|
||||||
return login(req.body)
|
return login(req.body)
|
||||||
@@ -21,7 +22,7 @@ app.post(`${route}/login`, (req, res) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post(`${route}/entradaInvitado`, (req, res) => {
|
app.post(`${route}/entradaInvitado`, verificaToken, (req, res) => {
|
||||||
return entradaInvitado(req.body)
|
return entradaInvitado(req.body)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
res.status(200).json(data);
|
res.status(200).json(data);
|
||||||
@@ -31,7 +32,7 @@ app.post(`${route}/entradaInvitado`, (req, res) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get(`${route}/adscripciones`, (req, res) => {
|
app.get(`${route}/adscripciones`, verificaToken, (req, res) => {
|
||||||
return adscripciones()
|
return adscripciones()
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
res.status(200).json(data);
|
res.status(200).json(data);
|
||||||
@@ -41,7 +42,7 @@ app.get(`${route}/adscripciones`, (req, res) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get(`${route}/premiaciones`, (req, res) => {
|
app.get(`${route}/premiaciones`, verificaToken, (req, res) => {
|
||||||
return premiaciones(req.query)
|
return premiaciones(req.query)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
res.status(200).json(data);
|
res.status(200).json(data);
|
||||||
@@ -51,9 +52,19 @@ app.get(`${route}/premiaciones`, (req, res) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.get(`${route}/yaRegistro`, verificaToken, (req, res) => {
|
||||||
|
return yaRegistro(req.query)
|
||||||
|
.then((data) => {
|
||||||
|
res.status(200).json(data);
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
res.status(400).json({ message: err.message });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
app.post(
|
app.post(
|
||||||
`${route}/cargarDatos`,
|
`${route}/cargarDatos`,
|
||||||
// verificaToken,
|
verificaToken,
|
||||||
upload.single('file'),
|
upload.single('file'),
|
||||||
(req, res) => {
|
(req, res) => {
|
||||||
if (req.file) {
|
if (req.file) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
const express = require('express');
|
const express = require('express');
|
||||||
const app = express();
|
const app = express();
|
||||||
// const { verificaToken } = require('../middleware/autentificacion');
|
const { verificaToken } = require('../middleware/autentificacion');
|
||||||
const route = '/usuario';
|
const route = '/usuario';
|
||||||
const controllerPath = '../controller/Usuario';
|
const controllerPath = '../controller/Usuario';
|
||||||
const loginAdmin = require(`${controllerPath}/loginAdmin`);
|
const loginAdmin = require(`${controllerPath}/loginAdmin`);
|
||||||
@@ -27,7 +27,7 @@ app.post(`${route}/loginOperador`, (req, res) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post(`${route}/nuevoOperador`, (req, res) => {
|
app.post(`${route}/nuevoOperador`, verificaToken, (req, res) => {
|
||||||
return nuevoOperador(req.body)
|
return nuevoOperador(req.body)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
res.status(200).json(data);
|
res.status(200).json(data);
|
||||||
|
|||||||
Reference in New Issue
Block a user