This commit is contained in:
Jay
2017-04-26 17:26:36 +08:00
parent b07e51ef7c
commit 712a78c4ed
4 changed files with 202 additions and 2 deletions
+44
View File
@@ -355,6 +355,50 @@ router
.catch(err => rt.err(res, err, n, 'ERR8000'));
})
.post('/getwristbandhealthinfo', (req, res, n) => {
if (!config.permission.wristband) return n('ERR9000');
let arr = req.body;
if (!arr.data) return n('ERR0000');
if (!arr.data.mac) return n('ERR0060');
if (!arr.data.stime || !arr.data.etime) return n('ERR0015');
let pros = [];
let query = "select log.* \
from ??.?? log \
where \
log.`wphylogmac` = ? \
and log.`wphylogtst` >= ? \
and log.`wphylogtst` <= ? \
order by log.`wphylogtst` desc";
let param = [config.db.db9, 'wphylog', arr.data.mac, arr.data.stime, arr.data.etime];
pros.push(tool.promiseQuery(res, query, param, 'record'));
let rtq = "select * from ??.?? where `mac` = ?";
let rtp = [config.db.db9, 'wristband', arr.data.mac];
pros.push(tool.promiseQuery(res, rtq, rtp, 'rt'));
res.api_res = {
record: [],
rt: {
wristband: []
}
}
Promise.all(pros)
.then(d => {
for (let i in d) {
let tmp = d[i];
if (tmp.key == 'rt') {
res.api_res.rt.wristband = tool.checkArray(tmp.data);
}
if (tmp.key == 'record') {
res.api_res.record = tool.checkArray(tmp.data);
}
}
return n();
})
.catch(err => rt.err(res, err, n, 'ERR8000'));
})
.post('/getlocationlist', (req, res, n) => {
if (!config.permission.wristband) return n('ERR9000');