From 699635202922e2d43668a187f9538db4dcc28855 Mon Sep 17 00:00:00 2001 From: nelo Date: Wed, 14 Jun 2017 12:55:10 +0200 Subject: [PATCH] get warehouses --- .../methods/warehouse/list-warehouses.js | 24 +++++++++++++ .../production/common/models/warehouse.js | 9 +++++ .../production/common/models/warehouse.json | 35 +++++++++++++++++++ services/production/server/model-config.json | 4 +++ 4 files changed, 72 insertions(+) create mode 100644 services/production/common/methods/warehouse/list-warehouses.js create mode 100644 services/production/common/models/warehouse.js create mode 100644 services/production/common/models/warehouse.json diff --git a/services/production/common/methods/warehouse/list-warehouses.js b/services/production/common/methods/warehouse/list-warehouses.js new file mode 100644 index 000000000..326244943 --- /dev/null +++ b/services/production/common/methods/warehouse/list-warehouses.js @@ -0,0 +1,24 @@ +module.exports = function(Warehouse) { + Warehouse.remoteMethod('list', { + description: 'List production warehouses', + returns: { + arg: 'warehouses', + type: 'object' + }, + http: { + verb: 'get', + path: '/list' + } + }); + + Warehouse.list = function(cb) { + Warehouse.find(where(), function(err, warehouses){ + if(!err) + cb(null, warehouses); + }); + }; + + var where = function(){ + return {"where": {"tpv": {"neq": 0}}} + } +} \ No newline at end of file diff --git a/services/production/common/models/warehouse.js b/services/production/common/models/warehouse.js new file mode 100644 index 000000000..b46253ae1 --- /dev/null +++ b/services/production/common/models/warehouse.js @@ -0,0 +1,9 @@ +var app = require('../../server/server'); + +module.exports = function(Warehouse) { + var models = app.models; + + // Methods + + require('../methods/warehouse/list-warehouses.js')(Warehouse); +}; \ No newline at end of file diff --git a/services/production/common/models/warehouse.json b/services/production/common/models/warehouse.json new file mode 100644 index 000000000..208914085 --- /dev/null +++ b/services/production/common/models/warehouse.json @@ -0,0 +1,35 @@ +{ + "name": "Warehouse", + "base": "MyModel", + "validateUpsert": true, + "properties": { + "id": { + "id": true, + "type": "Number", + "forceId": false + }, + "name": { + "type": "String" + }, + "tpv": { + "type": "Number" + }, + "inventary": { + "type": "Number" + } + }, + "acls": [ + { + "accessType": "*", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "DENY" + }, + { + "accessType": "*", + "principalType": "ROLE", + "principalId": "root", + "permission": "ALLOW" + } + ] +} diff --git a/services/production/server/model-config.json b/services/production/server/model-config.json index 7f29155b0..edfa734b5 100644 --- a/services/production/server/model-config.json +++ b/services/production/server/model-config.json @@ -52,5 +52,9 @@ "TicketState":{ "dataSource": "vn", "public": true + }, + "Warehouse":{ + "dataSource": "vn", + "public": true } }