feat: refs #6869 define model
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jorge Penadés 2024-11-11 13:02:09 +01:00
parent e0ffc2840b
commit a41fc36f90
6 changed files with 36 additions and 54 deletions

View File

@ -79,6 +79,9 @@
"ImageCollectionSize": {
"dataSource": "vn"
},
"ImageConfig": {
"dataSource": "vn"
},
"ImageContainer": {
"dataSource": "imageStorage"
},

View File

@ -0,0 +1,22 @@
{
"name": "ImageConfig",
"base": "VnModel",
"options": {
"mysql": {
"table": "hedera.imageConfig"
}
},
"properties": {
"url": {
"type": "string"
}
},
"acls": [
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$authenticated",
"permission": "ALLOW"
}
]
}

View File

@ -1,51 +0,0 @@
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,5 +5,4 @@ module.exports = Self => {
require('../methods/item-shelving/getAlternative')(Self);
require('../methods/item-shelving/updateFromSale')(Self);
require('../methods/item-shelving/getListItemNewer')(Self);
require('../methods/item-shelving/getItems')(Self);
};

View File

@ -41,6 +41,9 @@
},
"available": {
"type": "number"
},
"buyFk": {
"type": "number"
}
},
"relations": {

View File

@ -44,6 +44,12 @@
"type": "belongsTo",
"model": "Worker",
"foreignKey": "id"
},
"itemShelving": {
"type": "hasMany",
"model": "ItemShelving",
"foreignKey": "shelvingFk",
"primaryKey": "code"
}
}
}