Tarea #551 /workerMana/getCurrentWorkerMana.js
This commit is contained in:
parent
7f6f99dc49
commit
b558d79757
|
@ -14,7 +14,16 @@ module.exports = Self => {
|
|||
});
|
||||
|
||||
Self.getCurrentWorkerMana = async ctx => {
|
||||
let loggedWorkerId = ctx.req.accessToken.userId;
|
||||
return await Self.rawSql(`SELECT used AS mana FROM vn.manaSpellers WHERE worker = ?`, [loggedWorkerId]);
|
||||
let currentClientId = ctx.req.accessToken.userId;
|
||||
let currentWorker = await Self.app.models.Worker.findOne({
|
||||
where: {userFk: currentClientId},
|
||||
fields: 'id'
|
||||
});
|
||||
let currentWorkerMana = await Self.app.models.WorkerMana.findOne({
|
||||
where: {workerFk: currentWorker.id},
|
||||
fields: 'amount'
|
||||
});
|
||||
|
||||
return currentWorkerMana ? currentWorkerMana.amount : 0;
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue