2024-02-29 13:15:31 +00:00
|
|
|
import {sqliteConnection as con} from "../../index";
|
|
|
|
|
2018-12-16 03:49:59 +00:00
|
|
|
interface formatoDataARecibir {
|
|
|
|
opcion_ID: number,
|
|
|
|
num_ep: number,
|
|
|
|
visitas: number,
|
|
|
|
link: string,
|
|
|
|
peso: string
|
|
|
|
}
|
|
|
|
|
2024-02-29 13:15:31 +00:00
|
|
|
export const crearLink = (req: any, res: any) => {
|
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)} )`;
|
2024-02-29 13:15:31 +00:00
|
|
|
con.query(query, (err) => {
|
2018-12-21 00:13:51 +00:00
|
|
|
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
|
|
|
|
|
|
|
};
|