carrera
This commit is contained in:
@@ -2,6 +2,7 @@ const { obtenerDatosUsr } = require('../../config/mariadb.conf');
|
||||
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 = validarNumeroCuenta(
|
||||
@@ -11,15 +12,24 @@ const escolares = async (body) => {
|
||||
);
|
||||
return Usuario.findOne({
|
||||
where: { numeroCuenta },
|
||||
}).then((res) => {
|
||||
}).then(async (res) => {
|
||||
if (!res) {
|
||||
return obtenerDatosUsr(numeroCuenta).then(async (res) => {
|
||||
await Usuario.create({
|
||||
const datosUsuario = await obtenerDatosUsr(numeroCuenta);
|
||||
return Carrera.findOne({
|
||||
where: { idCarrera: datosUsuario.id_carrera },
|
||||
}).then(async (res) => {
|
||||
if (!res) {
|
||||
await Carrera.create({
|
||||
idCarrera: datosUsuario.id_carrera,
|
||||
carrera: body.carrera,
|
||||
});
|
||||
}
|
||||
return Usuario.create({
|
||||
numeroCuenta,
|
||||
nombre: body.nombre,
|
||||
generacion: res.generacion,
|
||||
generacion: datosUsuario.generacion,
|
||||
carrera: body.carrera,
|
||||
idCarrera: res.id_carrera,
|
||||
idCarrera: datosUsuario.id_carrera,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user