30 lines
841 B
JavaScript
30 lines
841 B
JavaScript
module.exports = Self => {
|
|
Self.remoteMethodCtx('getCurrentWorkerMana', {
|
|
description: 'Returns the mana of the logged worker',
|
|
accessType: 'READ',
|
|
accepts: [],
|
|
returns: {
|
|
type: 'number',
|
|
root: true
|
|
},
|
|
http: {
|
|
path: `/getCurrentWorkerMana`,
|
|
verb: 'GET'
|
|
}
|
|
});
|
|
|
|
Self.getCurrentWorkerMana = async ctx => {
|
|
let userId = ctx.req.accessToken.userId;
|
|
|
|
console.log(userId);
|
|
let workerMana = await Self.app.models.WorkerMana.findOne({
|
|
where: {workerFk: userId},
|
|
fields: 'amount'
|
|
});
|
|
let workerMana1 = await Self.app.models.WorkerMana.find();
|
|
console.log(workerMana);
|
|
console.log(workerMana1);
|
|
return workerMana ? workerMana.amount : 0;
|
|
};
|
|
};
|