change state ticket
This commit is contained in:
parent
e09f60a53a
commit
6adc734f69
|
@ -0,0 +1,46 @@
|
|||
module.exports = function(TicketState) {
|
||||
TicketState.remoteMethod('changeState', {
|
||||
description: 'Change state of tickets',
|
||||
accepts: [
|
||||
{
|
||||
arg: 'tickets',
|
||||
type: 'array',
|
||||
required: true,
|
||||
description: 'Array of tickets',
|
||||
http: {source: 'path'}
|
||||
},
|
||||
{
|
||||
arg: 'state',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'New state',
|
||||
http: {source: 'path'}
|
||||
},
|
||||
],
|
||||
returns: {
|
||||
arg: 'response',
|
||||
type: 'boolean'
|
||||
},
|
||||
http: {
|
||||
verb: 'put',
|
||||
path: '/:tickets/:state/changeState'
|
||||
}
|
||||
});
|
||||
|
||||
TicketState.changeState = function(tickets, state, cb) {
|
||||
changeState(tickets, state, cb);
|
||||
};
|
||||
|
||||
var changeState = function(tickets, state, cb){
|
||||
TicketState.update(where(tickets), {"state": state}, function(error, response){
|
||||
if(!error)
|
||||
cb(null, true);
|
||||
cb(error);
|
||||
});
|
||||
}
|
||||
|
||||
var where = function(tickets){
|
||||
return {"where": {"ticketFk": {"inq": tickets } } };
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
var app = require('../../server/server');
|
||||
|
||||
module.exports = function(TicketState) {
|
||||
var models = app.models;
|
||||
|
||||
// Methods
|
||||
|
||||
require('../methods/ticket-state/change-state.js')(TicketState);
|
||||
};
|
Loading…
Reference in New Issue