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 => {
2023-06-01 06:32:06 +00:00
Self.remoteMethodCtx('landsThatDay', {
2018-07-09 11:54:43 +00:00
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'
}
});
2023-06-01 06:32:06 +00:00
Self.landsThatDay = async(ctx, addressFk, landed, options) => {
const myOptions = {userId: ctx.req.accessToken.userId};
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
};
};