7430_devToTest #2490

Merged
alexm merged 306 commits from 7430_devToTest into test 2024-05-21 09:15:04 +00:00
2 changed files with 39 additions and 0 deletions
Showing only changes of commit c061841cac - Show all commits

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'
});
};