2024-02-29 13:15:31 +00:00
|
|
|
import {sqliteConnection as con} from "../../index";
|
|
|
|
|
2018-12-16 03:49:59 +00:00
|
|
|
interface respuestaLinks {
|
|
|
|
opcion_ID: number,
|
|
|
|
links_ID: number,
|
|
|
|
num_opcion: number,
|
|
|
|
formato: string,
|
|
|
|
res: string,
|
|
|
|
servidor: string,
|
|
|
|
color: string
|
|
|
|
}
|
|
|
|
|
2024-02-29 13:15:31 +00:00
|
|
|
export const obtenerVariantes = (req: any, res: any) => {
|
2018-12-16 03:49:59 +00:00
|
|
|
|
|
|
|
const YAML = require('yaml');
|
|
|
|
|
|
|
|
const anime_ID: string = req.params.anime_ID;
|
|
|
|
|
2018-12-21 00:13:51 +00:00
|
|
|
if (anime_ID) {
|
2018-12-16 03:49:59 +00:00
|
|
|
|
2018-12-21 00:13:51 +00:00
|
|
|
const query = `SELECT * FROM links_opciones WHERE links_ID=(SELECT links_ID FROM links WHERE anime_ID=${anime_ID})`;
|
2018-12-16 03:49:59 +00:00
|
|
|
|
2024-02-29 13:15:31 +00:00
|
|
|
con.query (query, (err, response: respuestaLinks[]) => {
|
2018-12-21 00:13:51 +00:00
|
|
|
if (!err) {
|
2018-12-16 03:49:59 +00:00
|
|
|
|
2018-12-21 00:13:51 +00:00
|
|
|
res.send(YAML.stringify(response));
|
2018-12-16 03:49:59 +00:00
|
|
|
|
2018-12-21 00:13:51 +00:00
|
|
|
} else {
|
|
|
|
console.log("Error al ejecutar query sql. La query era:\n" + query + "\n y el error es:\n" + err);
|
|
|
|
res.send("error: true");
|
|
|
|
}
|
|
|
|
});
|
2018-12-16 03:49:59 +00:00
|
|
|
|
2018-12-21 00:13:51 +00:00
|
|
|
} else {
|
|
|
|
console.log("Error. anime_ID no existe en Admin/Eps/obtenerVariantes con.connect:\n" + anime_ID);
|
|
|
|
res.send("error: true");
|
|
|
|
}
|
2018-12-16 03:49:59 +00:00
|
|
|
|
|
|
|
};
|