feat: refs #6869 define model #3172

Merged
jorgep merged 7 commits from 6869-createGetDetails into dev 2024-11-18 10:08:21 +00:00
3 changed files with 52 additions and 30 deletions
Showing only changes of commit 5c054fe0d3 - Show all commits

View File

@ -1,30 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_get`(IN vSelf VARCHAR(8))
BEGIN
/**
* Lista artículos de itemshelving
*
* @param vSelf matrícula del carro
**/
SELECT ish.itemFk item,
i.name,
i.longName,
i.size,
ish.visible,
ish.packing,
ish.grouping,
p.code,
ish.id,
s.priority,
ish.isChecked,
ic.url,
ish.available,
ish.buyFk
FROM itemShelving ish
JOIN item i ON i.id = ish.itemFk
JOIN shelving s ON vSelf = s.code COLLATE utf8_unicode_ci
LEFT JOIN parking p ON s.parkingFk = p.id
JOIN hedera.imageConfig ic
WHERE ish.shelvingFk COLLATE utf8_unicode_ci = vSelf;
END$$
DELIMITER ;

View File

@ -0,0 +1,51 @@
module.exports = Self => {
Self.remoteMethod('getItems', {
description: 'shelving item list',
accessType: 'READ',
accepts: [{
arg: 'code',
type: 'string',
required: true,
description: 'Shelving code'
}],
returns: {
type: 'object',
root: true
},
http: {
path: `/getItems`,
verb: 'GET'
}
});
Self.getItems = async(code, options) => {
const models = Self.app.models;
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
const shelving = await models.Shelving.findOne({
fields: ['priority', 'parkingFk'],
include: {
relation: 'parking',
scope: {fields: ['code']}
},
where: {code}
}, myOptions);
const itemShelvings = await Self.find({
fields: ['itemFk', 'visible', 'packing', 'grouping', 'isChecked', 'available', 'buyFk'],
include: {
relation: 'item',
scope: {fields: ['name', 'longName', 'size']}
},
where: {shelvingFk: code}
}, myOptions);
return {
code: shelving.parking().code,
priority: shelving.priority,
itemShelvings,
};
// Add image from hedera.imageConfig
};
};

View File

@ -5,4 +5,5 @@ module.exports = Self => {
require('../methods/item-shelving/getAlternative')(Self); require('../methods/item-shelving/getAlternative')(Self);
require('../methods/item-shelving/updateFromSale')(Self); require('../methods/item-shelving/updateFromSale')(Self);
require('../methods/item-shelving/getListItemNewer')(Self); require('../methods/item-shelving/getListItemNewer')(Self);
require('../methods/item-shelving/getItems')(Self);
}; };