From 8e9f736cde3995d9ef3f501b4a6b595a5c5d5173 Mon Sep 17 00:00:00 2001 From: alexmorenograu <61759297+alexmorenograu@users.noreply.github.com> Date: Thu, 18 Mar 2021 16:12:45 +0100 Subject: [PATCH] separate collection and wagon --- methods/bindTicketShelving.js | 19 +++++++------------ methods/setCollection.js | 24 ++++++++++++++++++++++++ server.js | 1 + 3 files changed, 32 insertions(+), 12 deletions(-) create mode 100644 methods/setCollection.js diff --git a/methods/bindTicketShelving.js b/methods/bindTicketShelving.js index 88ab606..ec249a5 100644 --- a/methods/bindTicketShelving.js +++ b/methods/bindTicketShelving.js @@ -2,25 +2,20 @@ const express = require('express'); const router = express.Router(); // eslint-disable-line // const filter = require('../utilities/filter'); const select = require('../db/selectDB'); -const maxWagon = require('../db/maxWagon'); -router.get('/:collectionFk', async(req, res) => { - // var shelving = "BCD";///introducida por el usuario O en leida de la bbdd? - // var collectionFk = '273449'; - const collectionFk = req.params.collectionFk; - ticketCollection(collectionFk); +router.get('/:collectionShelving', async(req, res) => { + const collectionShelving = req.params.collectionShelving.split(','); + let collectionFk = 273449; + ticketShelving(collectionShelving, collectionFk); res.json({message: 'SUCCESS'}); }); module.exports = router; -function ticketCollection(collectionFk) {// parametro collectionFk +function ticketShelving(collectionShelving, collectionFk) {// parametro collectionFk select.select(collectionFk, function(err, data) { - maxWagon.maxWagon(collectionFk, function(err, max) { - // aqui iria una función para pedir el numero de shelvings correspondientes - let shelving = ['ABC', 'DFG', 'HIJ']; - insertTicket(data, shelving, max); - }); + // aqui iria una función para pedir el numero de shelvings correspondientes + insertTicket(data, collectionShelving, max); }); } diff --git a/methods/setCollection.js b/methods/setCollection.js new file mode 100644 index 0000000..32909f7 --- /dev/null +++ b/methods/setCollection.js @@ -0,0 +1,24 @@ +const express = require('express'); +const router = express.Router(); // eslint-disable-line +const select = require('../db/selectDB'); +const maxWagon = require('../db/maxWagon'); + +router.get('/:collectionFk', async(req, res) => { + // var collectionFk = '273449'; + const collectionFk = req.params.collectionFk; + let maxWagon = ticketCollection(collectionFk); + res.json({ + message: 'SUCCESS', + maxWagon: maxWagon + }); +}); + +module.exports = router; + +function ticketCollection(collectionFk) {// parametro collectionFk + select.select(collectionFk, function(err, data) { + maxWagon.maxWagon(collectionFk, function(err, max) { + return max; + }); + }); +} diff --git a/server.js b/server.js index fa3083b..2ed1a00 100644 --- a/server.js +++ b/server.js @@ -6,6 +6,7 @@ const logIn = require('./methods/logIn'); const dataLogIn = logIn.info; exports.dataLogIn = dataLogIn; +app.use('/getNumShelving', require('./methods/setCollection')); app.use('/bindShelving', require('./methods/bindShelvingTag')); app.use('/insertTicket', require('./methods/bindTicketShelving'));