filter update
This commit is contained in:
parent
31f1c80b25
commit
2060cc5671
|
@ -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);
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
|
|
@ -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;
|
||||
|
|
Reference in New Issue