fake son de tickets

my model tiene el meted raw sql
This commit is contained in:
nelo 2017-06-13 08:44:40 +02:00
parent e4f9420697
commit c24c126734
10 changed files with 1205 additions and 12 deletions

View File

@ -1,5 +1,6 @@
module.exports = function(self) {
self.setup = function() {
self.super_.setup.call(this);
@ -25,7 +26,14 @@ module.exports = function(self) {
for(let method in disableMethods) {
//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) {
this.remoteMethod(methodName, {

File diff suppressed because it is too large Load Diff

View File

@ -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);
}
}

View File

@ -1,8 +1,14 @@
{
"name": "Ticket",
"base": "PersistedModel",
"base": "MyModel",
"validateUpsert": true,
"properties": {},
"properties": {
"id": {
"id": true,
"type": "Number",
"forceId": false
}
},
"acls": [
{
"accessType": "*",

View File

@ -1,5 +1,6 @@
module.exports = function(self) {
self.setup = function() {
self.super_.setup.call(this);
@ -25,7 +26,14 @@ module.exports = function(self) {
for(let method in disableMethods) {
//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) {
this.remoteMethod(methodName, {

View File

@ -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"
}
]
}

View File

@ -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"
}
]
}

View File

@ -0,0 +1,9 @@
var app = require('../../server/server');
module.exports = function(Ticket) {
var models = app.models;
// Methods
require('../methods/ticket/list.js')(Ticket);
};

View File

@ -13,23 +13,44 @@
"./mixins"
]
},
"User": {
"dataSource": "db"
"user": {
"dataSource": "auth"
},
"AccessToken": {
"dataSource": "db",
"public": false
"dataSource": "auth",
"relations": {
"user": {
"type": "belongsTo",
"model": "user",
"foreignKey": "userId"
}
}
},
"ACL": {
"dataSource": "db",
"dataSource": "auth",
"public": false
},
"RoleMapping": {
"dataSource": "db",
"dataSource": "auth",
"public": false
},
"Role": {
"dataSource": "db",
"dataSource": "auth",
"public": false
},
"Account": {
"dataSource": "auth"
},
"Ticket": {
"dataSource": "vn",
"public": true
},
"State":{
"dataSource": "vn",
"public": true
},
"TicketState":{
"dataSource": "vn",
"public": true
}
}

View File

@ -1,5 +1,6 @@
module.exports = function(self) {
self.setup = function() {
self.super_.setup.call(this);
@ -25,7 +26,14 @@ module.exports = function(self) {
for(let method in disableMethods) {
//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) {
this.remoteMethod(methodName, {