36 lines
1.0 KiB
JavaScript
36 lines
1.0 KiB
JavaScript
|
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'}
|
||
|
},
|
||
|
],
|
||
|
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);
|
||
|
};
|
||
|
|
||
|
var changeWorker = function(worker, tickets, cb){
|
||
|
var inserts = [];
|
||
|
var FakeProduction = Ticket.app.models.FakeProduction;
|
||
|
|
||
|
FakeProduction.updateAll({ticketFk: {inq: tickets}}, {workerFk: worker}, function(err, info){
|
||
|
(err) ? cb(err, null) : cb(null, info);
|
||
|
});
|
||
|
}
|
||
|
}
|