diff --git a/images/4aae394ec0a164c2d2f9442f945bb01e.jpeg b/images/4aae394ec0a164c2d2f9442f945bb01e.jpeg new file mode 100644 index 0000000..d548844 Binary files /dev/null and b/images/4aae394ec0a164c2d2f9442f945bb01e.jpeg differ diff --git a/images/8.jpeg b/images/8.jpeg new file mode 100644 index 0000000..a77985c Binary files /dev/null and b/images/8.jpeg differ diff --git a/images/85c7996adf8a7024d6d5208afdfdaec2.png b/images/85c7996adf8a7024d6d5208afdfdaec2.png new file mode 100644 index 0000000..7c05c1a Binary files /dev/null and b/images/85c7996adf8a7024d6d5208afdfdaec2.png differ diff --git a/images/bd36943993ef57725e556b409ebce671.png b/images/bd36943993ef57725e556b409ebce671.png new file mode 100644 index 0000000..7c05c1a Binary files /dev/null and b/images/bd36943993ef57725e556b409ebce671.png differ diff --git a/server/controller/Admin/ticket.js b/server/controller/Admin/ticket.js new file mode 100644 index 0000000..ebe3c01 --- /dev/null +++ b/server/controller/Admin/ticket.js @@ -0,0 +1,15 @@ +// const validar = require('../../../helper/validar'); +const dbPath = '../../db/tablas'; +const Usuario = require(`${dbPath}/Usuario`); +const Inscripcion = require(`${dbPath}/Inscripcion`); + +const ticket = async (body) => { + return Inscripcion.findOne({ + where: { folio: body.folio }, + attributes: ['rutaTicket'], + }).then((res) => { + return res.rutaTicket; + }); +}; + +module.exports = ticket; diff --git a/server/controller/Admin/todasInscripciones.js b/server/controller/Admin/todasInscripciones.js index 8d83327..2479cab 100644 --- a/server/controller/Admin/todasInscripciones.js +++ b/server/controller/Admin/todasInscripciones.js @@ -8,7 +8,7 @@ const todasInscripciones = async (body) => { include: [ { model: Usuario, - attributes: ['numeroCuenta'], + attributes: ['idUsuario', 'numeroCuenta'], }, ], }); diff --git a/server/routes/Admin.js b/server/routes/Admin.js index d3d6fe3..9c869af 100644 --- a/server/routes/Admin.js +++ b/server/routes/Admin.js @@ -1,5 +1,7 @@ const express = require('express'); +const ticket = require('../controller/Admin/ticket'); const app = express(); +const fs = require('fs'); const route = '/Admin'; const controllerPath = '../controller/Admin'; const todasInscripciones = require(`${controllerPath}/todasInscripciones`); @@ -14,4 +16,16 @@ app.get(`${route}/todas_inscripciones`, (req, res) => { }); }); +app.get(`${route}/ticket`, (req, res) => { + return ticket(req.query) + .then((data) => { + res.writeHead(200, { 'content-type': `image/png` }); + fs.createReadStream(process.cwd() + '/' + data + '.jpeg').pipe(res); + // res.status(200).json(data); + }) + .catch((err) => { + res.status(400).json({ message: err.message }); + }); +}); + module.exports = app; diff --git a/server/routes/Usuario.js b/server/routes/Usuario.js index 566eef0..0602525 100644 --- a/server/routes/Usuario.js +++ b/server/routes/Usuario.js @@ -2,7 +2,7 @@ const express = require('express'); const app = express(); const fs = require('fs'); const multer = require('multer'); -const upload = multer({ dest: 'tickets/images' }); +const upload = multer({ dest: 'images' }); const { verificaToken } = require('../middleware/autentificacion'); const route = '/Usuario'; const controllerPath = '../controller/Usuario';