2018-12-16 03:49:59 +00:00
|
|
|
interface formatoDataARecibir {
|
|
|
|
opcion_ID: number,
|
|
|
|
num_ep: number,
|
|
|
|
visitas: number,
|
|
|
|
link: string,
|
|
|
|
peso: string
|
|
|
|
}
|
|
|
|
|
|
|
|
const crearLink = (req: any, res: any) => {
|
|
|
|
|
2018-12-21 00:13:51 +00:00
|
|
|
const con = require('../../index').conexionMySQL;
|
2018-12-16 03:49:59 +00:00
|
|
|
const YAML = require('yaml');
|
|
|
|
|
|
|
|
const parametros: formatoDataARecibir = YAML.parse(req.body.params);
|
|
|
|
|
2018-12-21 00:13:51 +00:00
|
|
|
|
|
|
|
if (parametros) {
|
|
|
|
|
|
|
|
const query = `INSERT INTO eps (opcion_ID, num_ep, visitas, link, peso) VALUES (${parametros.opcion_ID},
|
|
|
|
${parametros.num_ep}, ${parametros.visitas}, ${con.escape(parametros.link)}, ${con.escape(parametros.peso)} )`;
|
|
|
|
con.query(query, (err: Error) => {
|
|
|
|
if (!err) {
|
|
|
|
|
|
|
|
res.send("error: false");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
console.log("Error al ejecutar query en /Admin/Eps/crearEp -> con.query (linea 20). Query y error:\n" + query + "\n" + parametros);
|
|
|
|
res.send("error: true");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
console.log("Error. 'parametros' no existe en /Admin/Eps/crearEp -> con.connect (linea 16):\n" + parametros);
|
|
|
|
res.send("error: true");
|
|
|
|
}
|
2018-12-16 03:49:59 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports.crearLink = crearLink;
|