salix/services/loopback/common/methods/ticket/getShipped.js

37 lines
1.0 KiB
JavaScript
Raw Normal View History

const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
module.exports = Self => {
Self.remoteMethod('getShipped', {
description: 'Returns ticket available shipment date',
accessType: 'READ',
accepts: [{
arg: 'data',
type: 'Object',
required: true,
description: 'landed, addressFk, agencyModeFk',
http: {source: 'body'}
}],
returns: {
type: 'object',
root: true
},
http: {
path: `/getShipped`,
verb: 'POST'
}
});
Self.getShipped = async data => {
let agencyMode = await Self.app.models.AgencyMode.findById(data.agencyModeFk);
let params = [data.landed, data.addressFk, agencyMode.agencyFk];
let stmt = new ParameterizedSQL(`CALL vn.agencyHourGetShipped(?, ?, ?);`, params);
stmt.merge('SELECT * FROM tmp.agencyHourGetShipped');
let rows = await Self.rawStmt(stmt);
return rows[1][0];
};
};