7489-testToMaster #2515

Merged
alexm merged 329 commits from 7489-testToMaster into master 2024-05-28 05:30:19 +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'
});
};