Files
inscripciones_api/server/controller/Usuario/escolares.js
T

41 lines
1.0 KiB
JavaScript
Raw Normal View History

2022-01-30 23:50:17 -06:00
const {
obtenerIdCarrera,
obtenerCarrera,
} = require('../../config/mariadb.conf');
2022-01-24 14:33:16 -06:00
const validar = require('../../helper/validar');
const dbPath = '../../db/tablas';
const Carrera = require(`${dbPath}/Carrera`);
const Usuario = require(`${dbPath}/Usuario`);
const escolares = async (body) => {
return Usuario.findOne({
2022-01-27 00:15:05 -06:00
where: { numeroCuenta: body.numeroCuenta },
2022-01-26 00:21:54 -06:00
}).then((res) => {
if (!res) {
2022-01-30 23:50:17 -06:00
return obtenerIdCarrera(body.numeroCuenta).then(async (res) => {
return Usuario.create({
idUsuario: body.idUsuario,
numeroCuenta: body.numeroCuenta,
nombre: body.nombre,
semestre: 8,
carrera: body.carrera,
idCarrera: res.id_carrera,
});
2022-01-27 00:15:05 -06:00
});
2022-01-26 00:21:54 -06:00
}
return Usuario.findOne({
2022-01-27 00:15:05 -06:00
where: { numeroCuenta: body.numeroCuenta },
attributes: [
'idUsuario',
'numeroCuenta',
'nombre',
'semestre',
2022-01-30 23:50:17 -06:00
'idCarrera',
2022-01-27 00:15:05 -06:00
'carrera',
],
2022-01-24 14:33:16 -06:00
});
2022-01-26 00:21:54 -06:00
});
2022-01-24 14:33:16 -06:00
};
module.exports = escolares;