escolares
This commit is contained in:
Generated
+36
@@ -8,6 +8,7 @@
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"axios": "^0.21.0",
|
||||
"bcrypt": "^5.0.0",
|
||||
"body-parser": "^1.19.0",
|
||||
"colors": "^1.4.0",
|
||||
@@ -219,6 +220,14 @@
|
||||
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
|
||||
"integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI="
|
||||
},
|
||||
"node_modules/axios": {
|
||||
"version": "0.21.0",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.0.tgz",
|
||||
"integrity": "sha512-fmkJBknJKoZwem3/IKSSLpkdNXZeBu5Q7GA/aRsr2btgrptmSCxi2oFjZHqGdK9DoTil9PIHlPIZw2EcRJXRvw==",
|
||||
"dependencies": {
|
||||
"follow-redirects": "^1.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/balanced-match": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
|
||||
@@ -929,6 +938,20 @@
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/follow-redirects": {
|
||||
"version": "1.13.0",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.0.tgz",
|
||||
"integrity": "sha512-aq6gF1BEKje4a9i9+5jimNFIpq4Q1WiwBToeRK5NvZBd/TRsmW8BsJfOEGkr76TbOyPVD3OVDN910EcUNtRYEA==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "individual",
|
||||
"url": "https://github.com/sponsors/RubenVerborgh"
|
||||
}
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/forwarded": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz",
|
||||
@@ -3002,6 +3025,14 @@
|
||||
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
|
||||
"integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI="
|
||||
},
|
||||
"axios": {
|
||||
"version": "0.21.0",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.0.tgz",
|
||||
"integrity": "sha512-fmkJBknJKoZwem3/IKSSLpkdNXZeBu5Q7GA/aRsr2btgrptmSCxi2oFjZHqGdK9DoTil9PIHlPIZw2EcRJXRvw==",
|
||||
"requires": {
|
||||
"follow-redirects": "^1.10.0"
|
||||
}
|
||||
},
|
||||
"balanced-match": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
|
||||
@@ -3572,6 +3603,11 @@
|
||||
"unpipe": "~1.0.0"
|
||||
}
|
||||
},
|
||||
"follow-redirects": {
|
||||
"version": "1.13.0",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.0.tgz",
|
||||
"integrity": "sha512-aq6gF1BEKje4a9i9+5jimNFIpq4Q1WiwBToeRK5NvZBd/TRsmW8BsJfOEGkr76TbOyPVD3OVDN910EcUNtRYEA=="
|
||||
},
|
||||
"forwarded": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz",
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
"author": "cidwa",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"axios": "^0.21.0",
|
||||
"bcrypt": "^5.0.0",
|
||||
"body-parser": "^1.19.0",
|
||||
"colors": "^1.4.0",
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
const Servicio = require('../../db/tablas/Servicio');
|
||||
|
||||
const serviciosAdmin = (body) => {
|
||||
Servicio.findAll().then((res) => {
|
||||
return res;
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,15 @@
|
||||
const Servicio = require('../../db/tablas/Servicio');
|
||||
|
||||
const nuevo = (body) => {
|
||||
let idPrograma = body.idUsuarioResponsable;
|
||||
let idAlumno = body.idAlumno;
|
||||
let numeroCuenta = body.numeroCuenta;
|
||||
let creditos = body.creditos;
|
||||
let nombre = body.nombre;
|
||||
let correo = body.correo;
|
||||
let fechaInicio = boyd.fechaInicio;
|
||||
let fechaFin = boyd.fechaFin;
|
||||
let cartaAceptacion = body.cartaAceptacion;
|
||||
};
|
||||
|
||||
module.exports = nuevo;
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
const validar = require('../../helper/validar');
|
||||
require('../../config/config');
|
||||
const Usuario = require('../../db/tablas/Usuario');
|
||||
const axios = require('axios');
|
||||
|
||||
const escolares = async (body) => {
|
||||
let numeroCuenta = validar.validarNumeroCuenta(body.numeroCuenta);
|
||||
let alumno;
|
||||
|
||||
return axios({
|
||||
method: 'post',
|
||||
url: `${process.env.ESCOLARES}${numeroCuenta}`,
|
||||
data: `${process.env.ESCOLARES_PASS}`,
|
||||
})
|
||||
.then((res) => {
|
||||
let data = res.data;
|
||||
|
||||
if (!data.nombre || !data.carrconst || !data.avance)
|
||||
throw new Error(
|
||||
'El alumno no cumple con los requicitos para realizar el Servicio Social. Si cree que esto es erroneo comunicate con COESI.'
|
||||
);
|
||||
alumno = {
|
||||
nombre: data.nombre.trim(),
|
||||
carrera: data.carrconst.trim(),
|
||||
creditos: data.avance,
|
||||
};
|
||||
return Usuario.findOne({ where: { usuario: numeroCuenta } });
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res)
|
||||
return Usuario.create({
|
||||
usuario: numeroCuenta,
|
||||
activo: false,
|
||||
idTipoUsuario: 3,
|
||||
});
|
||||
return res;
|
||||
})
|
||||
.then((res) => {
|
||||
return { ...alumno, idUsuario: res.idUsuario };
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = escolares;
|
||||
|
||||
@@ -18,11 +18,17 @@ Usuario.init(
|
||||
},
|
||||
password: {
|
||||
type: DataTypes.STRING(20),
|
||||
allowNull: false,
|
||||
allowNull: true,
|
||||
defaultValue: null,
|
||||
},
|
||||
nombre: {
|
||||
type: DataTypes.STRING(20),
|
||||
allowNull: true,
|
||||
defaultValue: null,
|
||||
},
|
||||
activo: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
allowNull: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -40,6 +40,19 @@ const validarTexto = (texto, campo) => {
|
||||
return texto;
|
||||
};
|
||||
|
||||
const validarNumeroCuenta = (numeroCuenta) => {
|
||||
let campo = 'numero de cuenta';
|
||||
|
||||
noHay(numeroCuenta, campo);
|
||||
if (
|
||||
typeof numeroCuenta !== 'string' ||
|
||||
!validator.isNumeric(numeroCuenta, { no_symbols: true }) ||
|
||||
numeroCuenta.length > 9
|
||||
)
|
||||
noValido(campo);
|
||||
return numeroCuenta;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
validarCorreo,
|
||||
validarId,
|
||||
@@ -47,4 +60,5 @@ module.exports = {
|
||||
yaExiste,
|
||||
noValido,
|
||||
noHay,
|
||||
validarNumeroCuenta,
|
||||
};
|
||||
|
||||
+24
-13
@@ -1,21 +1,32 @@
|
||||
const express = require('express');
|
||||
const app = express();
|
||||
const route = '/usuario';
|
||||
const create = require('../controller/Usuario/create');
|
||||
const login = require('../controller/Usuario/login');
|
||||
const escolares = require('../controller/Usuario/escolares');
|
||||
// const create = require('../controller/Usuario/create');
|
||||
// const login = require('../controller/Usuario/login');
|
||||
|
||||
app.post(`${route}/create`, (req, res) => {
|
||||
return create(req.body)
|
||||
.then((data) => {
|
||||
res.status(201).json(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
res.status(400).json({ message: err.message });
|
||||
});
|
||||
});
|
||||
// app.post(`${route}/create`, (req, res) => {
|
||||
// return create(req.body)
|
||||
// .then((data) => {
|
||||
// res.status(201).json(data);
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// res.status(400).json({ message: err.message });
|
||||
// });
|
||||
// });
|
||||
|
||||
app.post(`${route}/login`, (req, res) => {
|
||||
return login(req.body)
|
||||
// app.post(`${route}/login`, (req, res) => {
|
||||
// return login(req.body)
|
||||
// .then((data) => {
|
||||
// res.status(201).json(data);
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// res.status(400).json({ message: err.message });
|
||||
// });
|
||||
// });
|
||||
|
||||
app.get(`${route}/escolares`, (req, res) => {
|
||||
return escolares(req.query)
|
||||
.then((data) => {
|
||||
res.status(201).json(data);
|
||||
})
|
||||
|
||||
@@ -3,6 +3,6 @@ const app = express();
|
||||
|
||||
// app.use(require('./'))
|
||||
app.use(require('./Status'));
|
||||
// app.use(require('./Usuario'));
|
||||
app.use(require('./Usuario'));
|
||||
|
||||
module.exports = app;
|
||||
|
||||
Reference in New Issue
Block a user