2018-01-29 11:37:54 +00:00
|
|
|
module.exports = function(Client) {
|
|
|
|
Client.remoteMethod('addressesPropagateRe', {
|
|
|
|
description: 'Change property isEqualizated in all client addresses',
|
|
|
|
accessType: 'WRITE',
|
|
|
|
accepts: [
|
|
|
|
{
|
|
|
|
arg: 'id',
|
|
|
|
type: 'string',
|
|
|
|
required: true,
|
|
|
|
description: 'Client id',
|
|
|
|
http: {source: 'path'}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
arg: 'data',
|
|
|
|
type: 'Object',
|
|
|
|
required: true,
|
|
|
|
description: 'data with new value',
|
|
|
|
http: {source: 'body'}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
returns: {
|
|
|
|
arg: 'data',
|
|
|
|
type: 'boolean',
|
|
|
|
root: true
|
|
|
|
},
|
|
|
|
http: {
|
|
|
|
path: `/:id/addressesPropagateRe`,
|
|
|
|
verb: 'patch'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
Client.addressesPropagateRe = (id, data, callback) => {
|
|
|
|
if (data.hasOwnProperty('isEqualizated')) {
|
|
|
|
Client.app.models.Address.updateAll({clientFk: id}, data, (err, info) => {
|
|
|
|
if (err)
|
|
|
|
return callback(err, null);
|
|
|
|
callback(null, true);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
callback(null, false);
|
|
|
|
}
|
|
|
|
};
|
2018-03-02 12:46:25 +00:00
|
|
|
};
|