Cambios en la tablas, y agregamos la confirmacion

This commit is contained in:
Andres2908
2022-03-15 00:23:09 -06:00
parent 80852bb2c9
commit e8305da5a3
6 changed files with 18 additions and 23 deletions
+5 -5
View File
@@ -8,17 +8,17 @@ const pool = mariadb.createPool({
database: process.env.SAT_DB,
});
const obtenerIdCarrera = async (numeroCuenta) => {
const obtenerDatosUsr = async (numeroCuenta) => {
const conn = await pool.getConnection().catch((err) => {
throw new Error('No se pudo conectar con la db. ' + err);
});
return conn
.query(`SELECT id_carrera FROM alumno WHERE id_cuenta = ${numeroCuenta}`)
.query(
`SELECT id_carrera, generacion FROM alumno WHERE id_cuenta = ${numeroCuenta}`
)
.then((rows) => {
conn.end();
// console.log(rows[0]);
// if (rows[0].length === 0) return null;
return rows[0];
})
.catch((err) => {
@@ -63,4 +63,4 @@ const usuarioInscrito = async (numeroCuenta, realizoPago) => {
});
};
module.exports = { obtenerIdCarrera, obtenerCarrera, usuarioInscrito };
module.exports = { obtenerDatosUsr, obtenerCarrera, usuarioInscrito };
+7 -10
View File
@@ -1,25 +1,22 @@
const {
obtenerIdCarrera,
obtenerCarrera,
} = require('../../config/mariadb.conf');
const validar = require('../../helper/validar');
const { obtenerDatosUsr } = require('../../config/mariadb.conf');
const { validarNumeroEntero } = require('../../helper/validar');
const dbPath = '../../db/tablas';
const Carrera = require(`${dbPath}/Carrera`);
const Usuario = require(`${dbPath}/Usuario`);
const escolares = async (body) => {
// const numeroCuenta = validar.validarNumeroCuenta(body.numeroCuenta);
const idUsuario = validarNumeroEntero(body.idUsuario, 'id Usuario', true);
return Usuario.findOne({
where: { numeroCuenta: body.numeroCuenta },
}).then((res) => {
if (!res) {
return obtenerIdCarrera(body.numeroCuenta).then(async (res) => {
return obtenerDatosUsr(body.numeroCuenta).then(async (res) => {
return Usuario.create({
idUsuario: body.idUsuario,
idUsuario,
numeroCuenta: body.numeroCuenta,
nombre: body.nombre,
semestre: 8,
generacion: res.generacion,
carrera: body.carrera,
idCarrera: res.id_carrera,
});
@@ -31,7 +28,7 @@ const escolares = async (body) => {
'idUsuario',
'numeroCuenta',
'nombre',
'semestre',
'generacion',
'idCarrera',
'carrera',
],
+2 -2
View File
@@ -1,9 +1,10 @@
const validar = require('../../helper/validar');
const dbPath = '../../db/tablas';
const Carrera = require(`${dbPath}/Carrera`);
const Inscripcion = require(`${dbPath}/Inscripcion`);
const inscripciones = async (body) => {
// const numeroCuenta = validar.validarNumeroCuenta(body.numeroCuenta);
return Inscripcion.findAll({
where: { idUsuario: body.idUsuario },
}).then((res) => {
@@ -13,7 +14,6 @@ const inscripciones = async (body) => {
attributes: [
'idInscripcion',
'validacion',
'confirmacion',
'folio',
'monto',
'idUsuario',
-1
View File
@@ -13,7 +13,6 @@ const login = async (body) => {
passwordUser: body.passwordUser,
};
console.log(numeroCuenta, body.passwordUser);
return axios
.post(
`https://venus.acatlan.unam.mx/conexionEscolares_test/ingresarAlumno`,
+2 -3
View File
@@ -18,10 +18,9 @@ Inscripcion.init(
type: DataTypes.INTEGER,
defaultValue: 2,
},
confirmacion: {
cancelacion: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false,
defaultValue: 0,
},
folio: {
type: DataTypes.STRING(10),
+2 -2
View File
@@ -22,8 +22,8 @@ Usuario.init(
allowNull: true,
defaultValue: null,
},
semestre: {
type: DataTypes.STRING(30),
generacion: {
type: DataTypes.STRING(5),
allowNull: false,
},
idCarrera: {