40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
module.exports = Self => {
|
|
Self.remoteMethodCtx('deny', {
|
|
description: 'Create a newticket and returns the new ID',
|
|
accessType: 'WRITE',
|
|
accepts: [{
|
|
arg: 'id',
|
|
type: 'Integer',
|
|
required: true,
|
|
description: 'The request ID',
|
|
}, {
|
|
arg: 'observation',
|
|
type: 'String',
|
|
required: true,
|
|
description: 'The request observation',
|
|
}],
|
|
returns: {
|
|
type: 'number',
|
|
root: true
|
|
},
|
|
http: {
|
|
path: `/:id/deny`,
|
|
verb: 'post'
|
|
}
|
|
});
|
|
|
|
Self.deny = async ctx => {
|
|
let userId = ctx.req.accessToken.userId;
|
|
let worker = await Self.app.models.Worker.findOne({where: {userFk: userId}});
|
|
|
|
let params = {
|
|
isOk: false,
|
|
atenderFk: worker.id,
|
|
observation: ctx.args.observation,
|
|
};
|
|
|
|
let request = await Self.app.models.TicketRequest.findById(ctx.args.id);
|
|
return request.updateAttributes(params);
|
|
};
|
|
};
|