45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
interface respuestaLinks {
|
|
opcion_ID: number,
|
|
links_ID: number,
|
|
num_opcion: number,
|
|
formato: string,
|
|
res: string,
|
|
servidor: string,
|
|
color: string
|
|
}
|
|
|
|
const obtenerVariantes = (req: any, res: any) => {
|
|
|
|
const con = require('../../mysql').obtenerConexionMySql();
|
|
const YAML = require('yaml');
|
|
|
|
const anime_ID: string = req.params.anime_ID;
|
|
|
|
con.connect((err: Error) => {
|
|
if (!err && anime_ID) {
|
|
|
|
const query = `SELECT * FROM links_opciones WHERE links_ID=(SELECT links_ID FROM links WHERE anime_ID=${anime_ID})`;
|
|
|
|
con.query (query, (err: Error, response: respuestaLinks[]) => {
|
|
if (!err) {
|
|
|
|
res.send(YAML.stringify(response));
|
|
|
|
} else {
|
|
console.log("Error al ejecutar query sql. La query era:\n" + query + "\n y el error es:\n" + err);
|
|
res.send("error: true");
|
|
}
|
|
});
|
|
|
|
} else if (!err) {
|
|
console.log("Error. anime_ID no existe en Admin/Eps/obtenerVariantes con.connect:\n" + anime_ID);
|
|
res.send("error: true");
|
|
} else {
|
|
console.log("Error al conectarse a la Base de Datos en Admin/Eps/obtenerVariantes con.connect:\n" + err);
|
|
res.send("error: true");
|
|
}
|
|
});
|
|
|
|
};
|
|
|
|
module.exports.obtenerVariantes = obtenerVariantes; |