Merge branch 'dev' of https://git.verdnatura.es/salix into dev
* 'dev' of https://git.verdnatura.es/salix: active salesperson service in progress
This commit is contained in:
commit
79438f31cb
|
@ -0,0 +1,44 @@
|
|||
module.exports = (Client) => {
|
||||
Client.remoteMethod('activeSalesPerson', {
|
||||
description: 'returns actives employees with salesperson role',
|
||||
accessType: 'READ',
|
||||
isStatic: true,
|
||||
accepts: [{
|
||||
arg: 'filter',
|
||||
type: 'Object',
|
||||
required: false,
|
||||
description: 'Filter defining where and paginated data',
|
||||
http: {source: 'query'}
|
||||
}],
|
||||
returns: {
|
||||
arg: 'data',
|
||||
type: 'Employee',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/activeSalesPerson`,
|
||||
verb: 'get'
|
||||
}
|
||||
});
|
||||
|
||||
Client.activeSalesPerson = (filter, callback) => {
|
||||
var filter = filter || {};
|
||||
|
||||
filter.include = [
|
||||
{
|
||||
"relation": "role",
|
||||
"scope": {
|
||||
"fields": ["name"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"relation": 'user'
|
||||
}];
|
||||
console.log(filter);
|
||||
Client.app.models.Employee.find(filter, (err, instances) => {
|
||||
if (err)
|
||||
callback(err, null);
|
||||
callback(null, instances);
|
||||
});
|
||||
};
|
||||
};
|
Loading…
Reference in New Issue