parent
e4f9420697
commit
c24c126734
|
@ -1,5 +1,6 @@
|
||||||
|
|
||||||
module.exports = function(self) {
|
module.exports = function(self) {
|
||||||
|
|
||||||
self.setup = function() {
|
self.setup = function() {
|
||||||
self.super_.setup.call(this);
|
self.super_.setup.call(this);
|
||||||
|
|
||||||
|
@ -25,7 +26,14 @@ module.exports = function(self) {
|
||||||
for(let method in disableMethods) {
|
for(let method in disableMethods) {
|
||||||
//this.disableRemoteMethod(method, disableMethods[method]);
|
//this.disableRemoteMethod(method, disableMethods[method]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
};
|
||||||
|
|
||||||
|
self.rawSql = function(query, params, cb) {
|
||||||
|
this.dataSource.connector.execute(query, params, function(error, response) {
|
||||||
|
cb(error, response);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
self.installMethod = function(methodName, filterCb) {
|
self.installMethod = function(methodName, filterCb) {
|
||||||
this.remoteMethod(methodName, {
|
this.remoteMethod(methodName, {
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,44 @@
|
||||||
|
var json = require("./list-fake.json");
|
||||||
|
|
||||||
|
module.exports = function(Ticket) {
|
||||||
|
Ticket.remoteMethod('list', {
|
||||||
|
description: 'List tickets for production',
|
||||||
|
/*accepts: {
|
||||||
|
arg: 'id',
|
||||||
|
type: 'number',
|
||||||
|
required: true,
|
||||||
|
description: 'Model id',
|
||||||
|
http: {source: 'path'}
|
||||||
|
},*/
|
||||||
|
returns: {
|
||||||
|
arg: 'tickets',
|
||||||
|
type: 'object'
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
verb: 'get',
|
||||||
|
path: '/list'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Ticket.list = function(cb) {
|
||||||
|
//list();
|
||||||
|
return fake(cb);
|
||||||
|
};
|
||||||
|
|
||||||
|
var fake = function(cb){
|
||||||
|
cb(null, json);
|
||||||
|
}
|
||||||
|
|
||||||
|
var list = function(){
|
||||||
|
var params = [1, 0];
|
||||||
|
|
||||||
|
var query = "CALL production_control_source(?, ?)"
|
||||||
|
|
||||||
|
var cb = function(error, res){
|
||||||
|
if(error) console.log(error);
|
||||||
|
else console.log(res);
|
||||||
|
};
|
||||||
|
|
||||||
|
Ticket.rawSql(query, params, cb);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,8 +1,14 @@
|
||||||
{
|
{
|
||||||
"name": "Ticket",
|
"name": "Ticket",
|
||||||
"base": "PersistedModel",
|
"base": "MyModel",
|
||||||
"validateUpsert": true,
|
"validateUpsert": true,
|
||||||
"properties": {},
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"id": true,
|
||||||
|
"type": "Number",
|
||||||
|
"forceId": false
|
||||||
|
}
|
||||||
|
},
|
||||||
"acls": [
|
"acls": [
|
||||||
{
|
{
|
||||||
"accessType": "*",
|
"accessType": "*",
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
|
|
||||||
module.exports = function(self) {
|
module.exports = function(self) {
|
||||||
|
|
||||||
self.setup = function() {
|
self.setup = function() {
|
||||||
self.super_.setup.call(this);
|
self.super_.setup.call(this);
|
||||||
|
|
||||||
|
@ -25,7 +26,14 @@ module.exports = function(self) {
|
||||||
for(let method in disableMethods) {
|
for(let method in disableMethods) {
|
||||||
//this.disableRemoteMethod(method, disableMethods[method]);
|
//this.disableRemoteMethod(method, disableMethods[method]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
};
|
||||||
|
|
||||||
|
self.rawSql = function(query, params, cb) {
|
||||||
|
this.dataSource.connector.execute(query, params, function(error, response) {
|
||||||
|
cb(error, response);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
self.installMethod = function(methodName, filterCb) {
|
self.installMethod = function(methodName, filterCb) {
|
||||||
this.remoteMethod(methodName, {
|
this.remoteMethod(methodName, {
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
{
|
||||||
|
"name": "State",
|
||||||
|
"base": "MyModel",
|
||||||
|
"validateUpsert": true,
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"id": true,
|
||||||
|
"type": "Number",
|
||||||
|
"forceId": false
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "String",
|
||||||
|
"required": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"acls": [
|
||||||
|
{
|
||||||
|
"accessType": "*",
|
||||||
|
"principalType": "ROLE",
|
||||||
|
"principalId": "$everyone",
|
||||||
|
"permission": "DENY"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"accessType": "*",
|
||||||
|
"principalType": "ROLE",
|
||||||
|
"principalId": "root",
|
||||||
|
"permission": "ALLOW"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
{
|
||||||
|
"name": "TicketState",
|
||||||
|
"base": "MyModel",
|
||||||
|
"validateUpsert": true,
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"id": true,
|
||||||
|
"type": "Number",
|
||||||
|
"forceId": false
|
||||||
|
},
|
||||||
|
"updated": {
|
||||||
|
"type": "Date",
|
||||||
|
"required": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"relations": {
|
||||||
|
"ticket": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "Ticket",
|
||||||
|
"foreignKey": "ticketFk"
|
||||||
|
},
|
||||||
|
"state": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "State",
|
||||||
|
"foreignKey": "stateFk"
|
||||||
|
},
|
||||||
|
"employee": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "Employee",
|
||||||
|
"foreignKey": "employeeFk"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"acls": [
|
||||||
|
{
|
||||||
|
"accessType": "*",
|
||||||
|
"principalType": "ROLE",
|
||||||
|
"principalId": "$everyone",
|
||||||
|
"permission": "DENY"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"accessType": "*",
|
||||||
|
"principalType": "ROLE",
|
||||||
|
"principalId": "root",
|
||||||
|
"permission": "ALLOW"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
var app = require('../../server/server');
|
||||||
|
|
||||||
|
module.exports = function(Ticket) {
|
||||||
|
var models = app.models;
|
||||||
|
|
||||||
|
// Methods
|
||||||
|
|
||||||
|
require('../methods/ticket/list.js')(Ticket);
|
||||||
|
};
|
|
@ -13,23 +13,44 @@
|
||||||
"./mixins"
|
"./mixins"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"User": {
|
"user": {
|
||||||
"dataSource": "db"
|
"dataSource": "auth"
|
||||||
},
|
},
|
||||||
"AccessToken": {
|
"AccessToken": {
|
||||||
"dataSource": "db",
|
"dataSource": "auth",
|
||||||
"public": false
|
"relations": {
|
||||||
|
"user": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "user",
|
||||||
|
"foreignKey": "userId"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"ACL": {
|
"ACL": {
|
||||||
"dataSource": "db",
|
"dataSource": "auth",
|
||||||
"public": false
|
"public": false
|
||||||
},
|
},
|
||||||
"RoleMapping": {
|
"RoleMapping": {
|
||||||
"dataSource": "db",
|
"dataSource": "auth",
|
||||||
"public": false
|
"public": false
|
||||||
},
|
},
|
||||||
"Role": {
|
"Role": {
|
||||||
"dataSource": "db",
|
"dataSource": "auth",
|
||||||
"public": false
|
"public": false
|
||||||
|
},
|
||||||
|
"Account": {
|
||||||
|
"dataSource": "auth"
|
||||||
|
},
|
||||||
|
"Ticket": {
|
||||||
|
"dataSource": "vn",
|
||||||
|
"public": true
|
||||||
|
},
|
||||||
|
"State":{
|
||||||
|
"dataSource": "vn",
|
||||||
|
"public": true
|
||||||
|
},
|
||||||
|
"TicketState":{
|
||||||
|
"dataSource": "vn",
|
||||||
|
"public": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
|
|
||||||
module.exports = function(self) {
|
module.exports = function(self) {
|
||||||
|
|
||||||
self.setup = function() {
|
self.setup = function() {
|
||||||
self.super_.setup.call(this);
|
self.super_.setup.call(this);
|
||||||
|
|
||||||
|
@ -25,7 +26,14 @@ module.exports = function(self) {
|
||||||
for(let method in disableMethods) {
|
for(let method in disableMethods) {
|
||||||
//this.disableRemoteMethod(method, disableMethods[method]);
|
//this.disableRemoteMethod(method, disableMethods[method]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
};
|
||||||
|
|
||||||
|
self.rawSql = function(query, params, cb) {
|
||||||
|
this.dataSource.connector.execute(query, params, function(error, response) {
|
||||||
|
cb(error, response);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
self.installMethod = function(methodName, filterCb) {
|
self.installMethod = function(methodName, filterCb) {
|
||||||
this.remoteMethod(methodName, {
|
this.remoteMethod(methodName, {
|
||||||
|
|
Loading…
Reference in New Issue