salix/modules/zone/back/methods/agency/landsThatDay.js

41 lines
1.1 KiB
JavaScript
Raw Normal View History

2018-07-09 11:54:43 +00:00
module.exports = Self => {
Self.remoteMethod('landsThatDay', {
description: 'Returns a list of agencies that can land a shipment on a day for an address',
2019-11-11 15:32:03 +00:00
accepts: [
{
arg: 'addressFk',
type: 'number',
required: true
}, {
arg: 'landed',
type: 'date',
required: true
}
],
2018-07-09 11:54:43 +00:00
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);
2019-11-10 13:13:55 +00:00
let query = `
2019-11-11 15:32:03 +00:00
CALL vn.zone_getAgency(?, ?);
2019-11-10 13:13:55 +00:00
SELECT * FROM tmp.zoneGetAgency;
DROP TEMPORARY TABLE tmp.zoneGetAgency;
`;
const result = await Self.rawSql(query, [addressFk, landed], myOptions);
2018-07-09 11:54:43 +00:00
2019-05-30 06:41:08 +00:00
return result[1];
2018-07-09 11:54:43 +00:00
};
};