merge conflicts

This commit is contained in:
Dani Herrero 2017-06-20 15:02:23 +02:00
commit 7c28d42be0
6 changed files with 94 additions and 45 deletions

View File

@ -25,7 +25,29 @@ module.exports = function(self) {
for(let method in disableMethods) { for(let method in disableMethods) {
//this.disableRemoteMethod(method, disableMethods[method]); //this.disableRemoteMethod(method, disableMethods[method]);
} }
this.remoteMethod('list', {
accepts: [
{
arg: 'filter',
type: 'object',
description: 'Filter defining where'
}
],
returns: {
type: [this.modelName],
root: true
},
http: {
verb: 'get',
path: '/list'
}
});
}; };
self.list = function(filter, cb) {};
self.rawSql = function(query, params, cb) { self.rawSql = function(query, params, cb) {
this.dataSource.connector.execute(query, params, function(error, response) { this.dataSource.connector.execute(query, params, function(error, response) {
cb(error, response); cb(error, response);

View File

@ -1,31 +1,26 @@
module.exports = function(State) { module.exports = function(State) {
State.remoteMethod('productionStates', { State.list = function(filter, cb) {
description: 'Get production states', State.find(where(filter), function(err, states) {
returns: {
arg: 'states',
type: 'object'
},
http: {
verb: 'get',
path: '/productionStates'
}
});
State.productionStates = function(cb) {
State.find(where(), function(err, states) {
if(!err){ if(!err){
cb(null, states); cb(null, states);
} }
}); });
}; };
function where() { function where(filter) {
if(!filter)
return { return {
where: { where: {
"order": {gt: 0} "order": {gt: 0 }
}, },
order: "order, name" order: "order, name"
} }
else{
filter.where.order = {gt: 0 };
filter.order = "order, name";
return filter;
}
} }
} }

View File

@ -2,13 +2,6 @@ module.exports = function(TicketState) {
TicketState.remoteMethodCtx('changeState', { TicketState.remoteMethodCtx('changeState', {
description: 'Change state of tickets', description: 'Change state of tickets',
accepts: [ accepts: [
{
arg: 'tickets',
type: 'array',
required: true,
description: 'Array of tickets',
http: {source: 'path'}
},
{ {
arg: 'state', arg: 'state',
type: 'number', type: 'number',
@ -23,11 +16,13 @@ module.exports = function(TicketState) {
}, },
http: { http: {
verb: 'put', verb: 'put',
path: '/:tickets/:state/changeState' path: '/:state/changeState'
} }
}); });
TicketState.changeState = function(ctx, tickets, state, cb) { TicketState.changeState = function(ctx, state, cb) {
var tickets = ctx.req.body.tickets;
TicketState.connectToService(ctx, "client"); TicketState.connectToService(ctx, "client");
TicketState.app.models.Employee.findOne({where: {userFk: ctx.req.accessToken.userId}}, function(err, emp){ TicketState.app.models.Employee.findOne({where: {userFk: ctx.req.accessToken.userId}}, function(err, emp){

View File

@ -1,18 +1,6 @@
module.exports = function(Warehouse) { module.exports = function(Warehouse) {
Warehouse.remoteMethod('list', { Warehouse.list = function(filter, cb) {
description: 'List production warehouses', Warehouse.find(where(filter), function(err, warehouses){
returns: {
type: [Warehouse],
root: true
},
http: {
verb: 'get',
path: '/list'
}
});
Warehouse.list = function(cb) {
Warehouse.find(where(), function(err, warehouses){
if(!err) if(!err)
cb(null, warehouses); cb(null, warehouses);
else else
@ -20,7 +8,12 @@ module.exports = function(Warehouse) {
}); });
}; };
var where = function(){ var where = function(filter){
if(!filter)
return {"where": {"tpv": {"neq": 0}}} return {"where": {"tpv": {"neq": 0}}}
else {
filter.where.tpv = {"neq": 0}
return filter;
}
} }
} }

View File

@ -25,7 +25,29 @@ module.exports = function(self) {
for(let method in disableMethods) { for(let method in disableMethods) {
//this.disableRemoteMethod(method, disableMethods[method]); //this.disableRemoteMethod(method, disableMethods[method]);
} }
this.remoteMethod('list', {
accepts: [
{
arg: 'filter',
type: 'object',
description: 'Filter defining where'
}
],
returns: {
type: [this.modelName],
root: true
},
http: {
verb: 'get',
path: '/list'
}
});
}; };
self.list = function(filter, cb) {};
self.rawSql = function(query, params, cb) { self.rawSql = function(query, params, cb) {
this.dataSource.connector.execute(query, params, function(error, response) { this.dataSource.connector.execute(query, params, function(error, response) {
cb(error, response); cb(error, response);

View File

@ -25,7 +25,29 @@ module.exports = function(self) {
for(let method in disableMethods) { for(let method in disableMethods) {
//this.disableRemoteMethod(method, disableMethods[method]); //this.disableRemoteMethod(method, disableMethods[method]);
} }
this.remoteMethod('list', {
accepts: [
{
arg: 'filter',
type: 'object',
description: 'Filter defining where'
}
],
returns: {
type: [this.modelName],
root: true
},
http: {
verb: 'get',
path: '/list'
}
});
}; };
self.list = function(filter, cb) {};
self.rawSql = function(query, params, cb) { self.rawSql = function(query, params, cb) {
this.dataSource.connector.execute(query, params, function(error, response) { this.dataSource.connector.execute(query, params, function(error, response) {
cb(error, response); cb(error, response);