refs #5919 locker and back
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Carlos Satorres 2023-10-10 13:58:33 +02:00
parent 3c58f86c2a
commit c061841cac
2 changed files with 39 additions and 0 deletions

View File

@ -0,0 +1,32 @@
module.exports = Self => {
Self.remoteMethod('chooseLocker', {
description: 'Returns an unoccupied locker for the employee',
accessType: 'WRITE',
accepts: [{
arg: 'filter',
type: 'Object',
description: 'Filter defining where and paginated data',
required: true
}],
returns: {
type: ['object'],
root: true
},
http: {
path: `/chooseLocker`,
verb: 'GET'
}
});
Self.chooseLocker = async filter => {
const query =
`SELECT l.code AS locker_code
FROM worker w
JOIN locker l ON w.sex = l.gender
WHERE w.id = ? AND l.workerFk IS NULL;
`[this.worker.id];
return Self.chooseLocker(query, filter);
};
};

View File

@ -0,0 +1,7 @@
module.exports = Self => {
require('../methods/worker/chooseLocker')(Self);
Self.validatesUniquenessOf('locker', {
message: 'This locker has already been assigned'
});
};