feat(bindShelving): add select from shelving
This commit is contained in:
parent
b9533f4790
commit
7659ee5a55
|
@ -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;
|
||||
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Reference in New Issue