feat(bindShelving): add select from shelving

This commit is contained in:
Alex Moreno 2022-03-30 14:58:29 +02:00
parent b9533f4790
commit 7659ee5a55
3 changed files with 21 additions and 18 deletions

11
db/selectShelving.js Normal file
View File

@ -0,0 +1,11 @@
const con = require('./connect');
function shelvingExist(shelving, callback) {
const consSql = `SELECT * FROM vn.shelving WHERE code = ?`;
con.query(consSql, shelving, function(err, result, fields) {
callback(null, result);
});
}
exports.shelvingExist = shelvingExist;

View File

@ -14,11 +14,13 @@ router.get('/:smartTagFk&:shelving&:level', async(req, res) => {
const result = bindShelvingTag(smartTagFk, shelving, level);
if (result == 'INVALID_PLATE')
res.json({message: 'MATRICULA INCORRECTA'});
throw new Error('CODIGO MATRICULA INCORRECTO');
else if (result == 'INVALID_TAG_CODE')
res.json({message: 'CODIGO DE ETIQUETA INCORRECTO'});
throw new Error('CODIGO DE ETIQUETA INCORRECTO');
else
res.json({message: 'SUCCESS'});
return;
});
module.exports = router;

View File

@ -1,24 +1,14 @@
const select = require('../db/selectShelving');
function isSmartTag(toFilter) {
const exp = /^A0A3B82[A-F0-9]{5}$/;
return exp.test(toFilter);
}
let n = true;
function isShelving(toFilter) {
if (!Array.isArray(toFilter)) {
let s = toFilter;
toFilter = Array;
toFilter[0] = s;
}
const exp = /^[A-Z]{3}$/;
for (let i = 0; i < toFilter.length; i++) {
let state = exp.test(toFilter[i]);
if (state == false)
n = false;
}
if (n == false)
return false;
else
return true;
console.log(select.shelvingExist(toFilter, function(err, data) {
console.log(data);
}));
return select.shelvingExist(toFilter);
}
exports.isSmartTag = isSmartTag;
exports.isShelving = isShelving;