我有一条路线,我想为每项服务执行不同的功能
var planning = require('../tms/planning.js');
router.get('/tms/api/:service', isAuthenticated, function(req, res, next) {
if (req.params.service == 'depot_planning') {
planning.depots(req, function(results) {
res.send({
'result': {
'data': results
}
});
});
} else if (req.params.service == 'affiche_planning') {
planning.AffichePlanning(req, function(result) {
res.send({
'result': {
'data': result
}
});
});
}
});
我打电话的功能
var t = require('./DB2connexion');
var database = t.database;
var depots = function(req, callback) {
statement = 'SELECT distinct plptrs FROM MTFPLAP';
database.execute(statement);
database.on('execute', function(error, results, next) {
if (error) {
console.log(error);
} else {
callback(results, next);
}
});
}
var AffichePlanning = function(req, callback) {
statement = 'SELECT otnump,otquai,OTHCR,Otnbps from MTFodtp where OTDCR=\'' + req.query.datePlanning +
'\' and ottype=\'CDE\' and OTLP=\'NOR\' order by otquai asc,OTHCR asc';
console.log(statement);
database.execute(statement);
database.on('execute', function(error, results) {
if (error) {
console.log(error);
} else {
callback(results, next);
}
});
}
module.exports.depots = depots;
module.exports.AffichePlanning = AffichePlanning;
当我执行我的代码时,我为两条路线返回了相同的结果,我怎样才能为每次调用取得好结果?