filter update

This commit is contained in:
alexmorenograu 2021-03-22 09:25:09 +01:00
parent 31f1c80b25
commit 2060cc5671
2 changed files with 17 additions and 5 deletions

View File

@ -2,14 +2,18 @@ const express = require('express');
const router = express.Router(); // eslint-disable-line
// const filter = require('../utilities/filter');
const select = require('../db/selectDB');
const filter = require('../utilities/filter');
router.get('/:collectionShelving&:collectionFk', async(req, res) => {
const collectionShelving = req.params.collectionShelving.split(',');
const collectionFk = req.params.collectionFk;
console.log(collectionShelving);
console.log(collectionFk);
ticketShelving(collectionShelving, collectionFk);
res.json({message: 'SUCCESS'});
if (filter.isShelving(collectionShelving)) {
ticketShelving(collectionShelving, collectionFk);
res.json({message: 'SUCCESS'});
} else
res.json({message: 'SHELVING ERROR'});
});
module.exports = router;
@ -34,7 +38,6 @@ function insertTicket(consultaSql, shelving) {
(async() => {
for (let i = 0; i < consultaSql.length; i++) {
console.log(i);
for (let j = 0; j < consultaSql[i].Level.toString().length; j++) {
const {body} = await got.post('http://app.etiquetaselectronicas.com:9999/item/batchImportItem', { // eslint-disable-line
json: {
@ -59,7 +62,7 @@ function insertTicket(consultaSql, shelving) {
'Authorization': key
}
});
console.log(body);
console.log(i, body);
}
}
})();

View File

@ -2,9 +2,18 @@ function isBarcode(toFilter) {
const exp = /^A0A3B82[A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9]$/;
return exp.test(toFilter);
}
let n = true;
function isShelving(toFilter) {
const exp = /^[A-Z][A-Z][A-Z]$/;
return exp.test(toFilter);
toFilter.forEach(element => {
let state = exp.test(element);
if (state == false)
n = false;
});
if (n == false)
return false;
else
return true;
}
exports.isBarcode = isBarcode;
exports.isShelving = isShelving;