From cbc364db3827bcc8df8a8e8fa197bdc90c6edb39 Mon Sep 17 00:00:00 2001 From: nelo Date: Tue, 13 Jun 2017 11:26:54 +0200 Subject: [PATCH] get states production --- .../production/common/methods/state/find.js | 31 +++++++++++++++++++ services/production/common/models/state.js | 9 ++++++ services/production/common/models/state.json | 14 ++++++++- .../common/models/ticket-state.json | 2 +- services/production/server/datasources.json | 27 +++++++++++++++- 5 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 services/production/common/methods/state/find.js create mode 100644 services/production/common/models/state.js diff --git a/services/production/common/methods/state/find.js b/services/production/common/methods/state/find.js new file mode 100644 index 0000000000..f40937891c --- /dev/null +++ b/services/production/common/methods/state/find.js @@ -0,0 +1,31 @@ +module.exports = function(State) { + State.remoteMethod('productionStates', { + description: 'Get production states', + returns: { + arg: 'states', + type: 'object' + }, + http: { + verb: 'get', + path: '/productionStates' + } + }); + + State.productionStates = function(cb) { + State.find(where(), function(err, states) { + if(!err){ + cb(null, states); + } + }); + }; + + function where() { + return { + where: { + "order": {gt: 0} + }, + order: "order, name" + } + } + +} \ No newline at end of file diff --git a/services/production/common/models/state.js b/services/production/common/models/state.js new file mode 100644 index 0000000000..aef20d4658 --- /dev/null +++ b/services/production/common/models/state.js @@ -0,0 +1,9 @@ +var app = require('../../server/server'); + +module.exports = function(State) { + var models = app.models; + + // Methods + + require('../methods/state/find.js')(State); +}; \ No newline at end of file diff --git a/services/production/common/models/state.json b/services/production/common/models/state.json index 97e2eecf33..9dff624327 100644 --- a/services/production/common/models/state.json +++ b/services/production/common/models/state.json @@ -3,7 +3,7 @@ "base": "MyModel", "validateUpsert": true, "properties": { - "id": { + "id": { "id": true, "type": "Number", "forceId": false @@ -11,6 +11,18 @@ "name": { "type": "String", "required": false + }, + "order":{ + "type": "Number", + "required": false + }, + "alertLevel":{ + "type": "Number", + "required": false + }, + "code":{ + "type": "String", + "required": false } }, "acls": [ diff --git a/services/production/common/models/ticket-state.json b/services/production/common/models/ticket-state.json index 5f919ff2ac..8ece52942b 100644 --- a/services/production/common/models/ticket-state.json +++ b/services/production/common/models/ticket-state.json @@ -3,7 +3,7 @@ "base": "MyModel", "validateUpsert": true, "properties": { - "id": { + "id": { "id": true, "type": "Number", "forceId": false diff --git a/services/production/server/datasources.json b/services/production/server/datasources.json index d6caf56d44..ba7db7577e 100644 --- a/services/production/server/datasources.json +++ b/services/production/server/datasources.json @@ -1,6 +1,31 @@ { "db": { "name": "db", - "connector": "memory" + "connector": "memory", + "file": "db.json" + }, + "auth": { + "name": "mysql", + "connector": "mysql", + "database": "salix", + "debug": false, + "host": "localhost", + "port": 3306, + "username": "root", + "password": "", + "connectTimeout": 20000, + "acquireTimeout": 20000 + }, + "vn": { + "name": "mysql", + "connector": "mysql", + "database": "salix", + "debug": false, + "host": "localhost", + "port": 3306, + "username": "root", + "password": "", + "connectTimeout": 20000, + "acquireTimeout": 20000 } }