33 lines
978 B
JavaScript
33 lines
978 B
JavaScript
|
|
module.exports = Self => {
|
|
Self.remoteMethod('activeWithInheritedRole', {
|
|
description: 'Returns active workers with an inherited role',
|
|
accessType: 'READ',
|
|
accepts: [{
|
|
arg: 'filter',
|
|
type: 'Object',
|
|
description: 'Filter defining where and paginated data',
|
|
required: true
|
|
}],
|
|
returns: {
|
|
type: ['object'],
|
|
root: true
|
|
},
|
|
http: {
|
|
path: `/activeWithInheritedRole`,
|
|
verb: 'GET'
|
|
}
|
|
});
|
|
|
|
Self.activeWithInheritedRole = async filter => {
|
|
const query =
|
|
`SELECT DISTINCT w.id, w.firstName, w.lastName, u.name, u.nickname
|
|
FROM worker w
|
|
JOIN account.user u ON u.id = w.id
|
|
JOIN account.roleRole i ON i.role = u.role
|
|
JOIN account.role r ON r.id = i.inheritsFrom`;
|
|
|
|
return Self.activeWorkers(query, filter);
|
|
};
|
|
};
|