commit e49bb60732aa6d235527dad83e57ca037b872abe Author: DanielRamirezGe Date: Fri Sep 20 20:05:20 2019 -0500 añadir la funcion del loggin, registar, obtener conferencias diff --git a/routes/getConferencias.js b/routes/getConferencias.js new file mode 100644 index 0000000..6e74075 --- /dev/null +++ b/routes/getConferencias.js @@ -0,0 +1,104 @@ +const connection = require('../conf/connection.js'); +const express = require('express') +var app = express(); + +var conferencias = { + dia1: { + conf1: { + nombre: "", + fecha: "", + asistir: false + }, + conf2: { + nombre: "", + fecha: "", + asistir: false + }, + conf3: { + nombre: "", + fecha: "", + asistir: false + } + + }, + dia2: { + conf1: { + nombre: "", + fecha: "", + asistir: false + }, + conf2: { + nombre: "", + fecha: "", + asistir: false + }, + conf3: { + nombre: "", + fecha: "", + asistir: false + } + }, + dia4: { + conf1: { + nombre: "", + fecha: "", + asistir: false + }, + conf2: { + nombre: "", + fecha: "", + asistir: false + }, + conf3: { + nombre: "", + fecha: "", + asistir: false + } + }, + dia5: { + conf1: { + nombre: "", + fecha: "", + asistir: false + }, + conf2: { + nombre: "", + fecha: "", + asistir: false + }, + conf3: { + nombre: "", + fecha: "", + asistir: false + } + } + +} + + +app.get('/getConferencias', (req, res) => { + + + connection.query(`select * from Conferencia ;`, function(error, results, fields) { + if (error) { + res.status(200).json({ err: true, mjs: 'error en la consulta de conferencia' }); + connection.end(); + return; + } + res.status(200).json({ results }); + for (let i = 1; i <= 5; i++) { + if (i < 3) { + for (let j = ((i - 1) * 3) + 1; j <= ((i - 1) * 3) + 3; j++) { + + } + } + } + return; + + }); + +}); + + + +module.exports = app; \ No newline at end of file diff --git a/routes/index.js b/routes/index.js new file mode 100644 index 0000000..a497109 --- /dev/null +++ b/routes/index.js @@ -0,0 +1,8 @@ +var express = require('express') +var app = express() + +app.use(require('./registro')); +app.use(require('./registroPersona')); +app.use(require('./loggin')); +app.use(require('./getConferencias')); +module.exports = app; \ No newline at end of file diff --git a/routes/loggin.js b/routes/loggin.js new file mode 100644 index 0000000..cea5d07 --- /dev/null +++ b/routes/loggin.js @@ -0,0 +1,52 @@ +const connection = require('../conf/connection.js'); +const express = require('express') + +var app = express(); + +app.get('/loggin', (req, res) => { + connection.query(`SELECT idPersona from Persona where correo = '${req.body.correo}' `, + function(error, results, fields) { + if (error) { + res.status(200).json({ err: true, mjs: 'error en la verificacion del correo' }); + + return; + } + if (results.length == 0) { + res.status(200).json({ err: true, mjs: 'Correo no registrado' }); + + return; + } else { + connection.query(`SELECT * from Persona where correo = '${req.body.correo}' and pasword= '${req.body.password}'`, + function(e, r, f) { + if (e) { + res.status(200).json({ err: true, mjs: 'error en la verificacion del de la contraseña' }); + + return; + } + //console.log(r, `'${req.body.correo}' and pasword= '${req.body.password}'`); + if (r.length == 0) { + res.status(200).json({ err: true, mjs: 'Datos Incorrectos' }); + + return; + } else { + // console.log(r[0].idPersona); + res.status(200).json({ err: false, mjs: 'Bienvenido', idPersona: r[0].idPersona, nombre: r[0].nombre }); + + return; + + } + }); + } + }); + +}); + +module.exports = app; + + + +// { +// "correo": "daniel.adrian.ramirez.george@gmail.com", +// "password": "georgechido" + +// } \ No newline at end of file diff --git a/routes/registro.js b/routes/registro.js new file mode 100644 index 0000000..71d69a3 --- /dev/null +++ b/routes/registro.js @@ -0,0 +1,20 @@ +const connection = require('../conf/connection.js'); +const express = require('express') + +var app = express() + +app.get('/registro', (req, res) => { + + connection.connect(); + + connection.query('SELECT * from Persona', function(error, results, fields) { + if (error) throw error; + res.status(400).json({ err: "huevos puto no tienes usuario" }) + }); +}); +app.post('/registro', (req, res) => { + if (!req.body.nombre) return res.status(400).json({ err: "falta el nombre" }) + res.status(200).json(req.body) +}) + +module.exports = app \ No newline at end of file diff --git a/routes/registroPersona.js b/routes/registroPersona.js new file mode 100644 index 0000000..f029202 --- /dev/null +++ b/routes/registroPersona.js @@ -0,0 +1,58 @@ +const connection = require('../conf/connection.js'); +const express = require('express') + +var app = express() + +app.post('/registroPersona', (req, res) => { + //console.log(req.body.correo); + connection.query(`SELECT * from Persona where correo='${req.body.correo}'; `, function(error, results, fields) { + if (error) { + res.status(200).json({ err: true, mjs: 'error en la comprobacion del correo' }); + connection.end(); + return; + } + console.log(results.length); + if (results.length == 0) { + connection.query(`insert into Persona values (${req.body.est}, '${req.body.noCuenta}', ${req.body.promedio}, + '${req.body.nombre}', '${req.body.apellidos}', '${req.body.sexo}', ${req.body.edad}, '${req.body.correo}', + '${req.body.nivelIngles}', '${req.body.comunidad}' , '${req.body.pasword}', '${req.body.facultdad}' , '${req.body.gradoAcademico}', + '${req.body.nombrePrograma}' , ${req.body.semestre}, ${req.body.titulado} );`, + function(e, r, f) { + if (e) { + res.status(200).json({ err: true, mjs: 'error al registrar en la base' }); + connection.end(); + return; + } + res.status(200).json({ err: false, msj: 'Registro completo' }); + + return; + }); + + } else { + res.status(200).json({ err: true, mjs: 'el correo ya esta registardo' }); + return; + } + + }); +}); + +module.exports = app; + + +// { +// "est" : null, +// "nombre" : "sasasaassa", +// "promedio" : 9.2, +// "apellidos" : "pica papas", +// "sexo" : "hombre", +// "edad" : 21, +// "correo" : "slllls@ga.cdsdsdsom", +// "nivelIngles" : "Avanzado", +// "comunidad" : "UNAM", +// "pasword" : "sasa8s88sa8", +// "facultdad" : "La mas chida", +// "gradoAcademico" : "Licenciatura", +// "nombrePrograma" : "carpintero", +// "semestre" : "8", +// "titulado" : false +// } \ No newline at end of file