salix/services/production/common/methods/ticket/change-worker.js

36 lines
1008 B
JavaScript
Raw Normal View History

2017-07-06 10:21:19 +00:00
module.exports = function(Ticket) {
Ticket.remoteMethodCtx('changeWorker', {
description: 'Change worker of tickets state',
accepts: [
{
arg: 'worker',
type: 'number',
required: true,
description: 'worker id',
http: {source: 'path'}
2017-10-25 11:47:39 +00:00
}
2017-07-06 10:21:19 +00:00
],
returns: {
arg: 'response',
type: 'boolean'
},
http: {
verb: 'put',
path: '/:worker/changeWorker'
}
});
Ticket.changeWorker = function(ctx, worker, cb) {
var tickets = ctx.req.body.tickets;
changeWorker(worker, tickets, cb);
};
2017-10-25 11:47:39 +00:00
let changeWorker = function(worker, tickets, cb) {
2017-07-06 10:21:19 +00:00
var FakeProduction = Ticket.app.models.FakeProduction;
FakeProduction.updateAll({ticketFk: {inq: tickets}}, {workerFk: worker}, function(err, info){
(err) ? cb(err, null) : cb(null, info);
});
2017-10-25 11:47:39 +00:00
};
};