41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
module.exports = Self => {
|
|
Self.remoteMethod('landsThatDay', {
|
|
description: 'Returns a list of agencies that can land a shipment on a day for an address',
|
|
accepts: [
|
|
{
|
|
arg: 'addressFk',
|
|
type: 'number',
|
|
required: true
|
|
}, {
|
|
arg: 'landed',
|
|
type: 'date',
|
|
required: true
|
|
}
|
|
],
|
|
returns: {
|
|
type: 'object',
|
|
root: true
|
|
},
|
|
http: {
|
|
path: `/landsThatDay`,
|
|
verb: 'get'
|
|
}
|
|
});
|
|
|
|
Self.landsThatDay = async(addressFk, landed, options) => {
|
|
const myOptions = {};
|
|
|
|
if (typeof options == 'object')
|
|
Object.assign(myOptions, options);
|
|
|
|
let query = `
|
|
CALL vn.zone_getAgency(?, ?);
|
|
SELECT * FROM tmp.zoneGetAgency;
|
|
DROP TEMPORARY TABLE tmp.zoneGetAgency;
|
|
`;
|
|
const result = await Self.rawSql(query, [addressFk, landed], myOptions);
|
|
|
|
return result[1];
|
|
};
|
|
};
|