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

36 lines
937 B
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'
}
});
2019-11-11 15:32:03 +00:00
Self.landsThatDay = async(addressFk, landed) => {
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;
`;
2019-11-11 15:32:03 +00:00
let result = await Self.rawSql(query, [addressFk, landed]);
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
};
};