update
This commit is contained in:
+44
-17
@@ -128,7 +128,7 @@ router
|
||||
.post('/getstatus', (req, res, n) => {
|
||||
if (!config.permission.wristband) return n('ERR9000');
|
||||
|
||||
let query = "select w.`name`, coalesce(l.`name`, l2.`name`) as locname, ll.*\
|
||||
let query = "select w.`name`, w.`mac` as wristband, coalesce(l.`name`, l2.`name`) as locname, ll.*\
|
||||
from ??.?? w\
|
||||
left join ( \
|
||||
select * from ( \
|
||||
@@ -145,7 +145,8 @@ router
|
||||
left join ??.?? l2\
|
||||
on \
|
||||
l2.`serialnumber` = ll.`devid` \
|
||||
";
|
||||
where \
|
||||
w.`switch` = 1 ";
|
||||
let param = [config.db.db9, 'wristband', config.db.db9, 'rawdata', config.db.db9, 'lastdata', config.db.db9, 'location', config.db.db9, 'location', ];
|
||||
|
||||
let sortfield = '';
|
||||
@@ -233,25 +234,32 @@ router
|
||||
if (!arr.data) return n('ERR0000')
|
||||
if (!arr.data.mac) return n('ERR0060');
|
||||
|
||||
let name = arr.data.name || '';
|
||||
let identity = arr.data.identity || 0;
|
||||
let monitor = arr.data.monitor || 0;
|
||||
let notify = arr.data.notify || 0;
|
||||
let sw = arr.data.switch || 0;
|
||||
|
||||
let query = "insert into ??.?? (`mac`, `name`, `identity`, `monitor`, `notify`, `switch`, `ctime`, `mtime`) values \
|
||||
( ?, ?, ?, ?, ?, ?, unix_timestamp(), unix_timestamp() )";
|
||||
let param = [config.db.db9, 'wristband', arr.data.mac, name, identity, monitor, notify, sw];
|
||||
let query = "select count(*) as c from ??.?? where `mac` = ?";
|
||||
let param = [config.db.db9, 'wristband', arr.data.mac];
|
||||
|
||||
res.db.query(query, param, (err, row) => {
|
||||
if (err) return rt.err(res, err, n, 'ERR8001');
|
||||
if (err || row.length == 0) return rt.err(res, err, n, "ERR8000");
|
||||
if (row[0].c > 0) return n("ERR0061");
|
||||
|
||||
res.api_res = {
|
||||
record: []
|
||||
};
|
||||
n();
|
||||
});
|
||||
let name = arr.data.name || '';
|
||||
let identity = arr.data.identity || 0;
|
||||
let monitor = arr.data.monitor || 0;
|
||||
let notify = arr.data.notify || 0;
|
||||
let sw = arr.data.switch || 0;
|
||||
|
||||
let query = "insert into ??.?? (`mac`, `name`, `identity`, `monitor`, `notify`, `switch`, `ctime`, `mtime`) values \
|
||||
( ?, ?, ?, ?, ?, ?, unix_timestamp(), unix_timestamp() )";
|
||||
let param = [config.db.db9, 'wristband', arr.data.mac, name, identity, monitor, notify, sw];
|
||||
|
||||
res.db.query(query, param, (err, row) => {
|
||||
if (err) return rt.err(res, err, n, 'ERR8001');
|
||||
|
||||
res.api_res = {
|
||||
record: []
|
||||
};
|
||||
n();
|
||||
});
|
||||
})
|
||||
})
|
||||
.post('/editwristband', (req, res, n) => {
|
||||
if (!config.permission.wristband) return n('ERR9000');
|
||||
@@ -285,6 +293,25 @@ router
|
||||
n();
|
||||
})
|
||||
})
|
||||
.post('/getlocationlist', (req, res, n) => {
|
||||
if (!config.permission.wristband) return n('ERR9000');
|
||||
|
||||
let query = "select * from ??.??";
|
||||
let param = [config.db.db9, 'location'];
|
||||
|
||||
res.db.query(query, param, (err, row) => {
|
||||
if (err) return rt.err(res, err, n, "ERR8000");
|
||||
|
||||
res.api_res = {
|
||||
record: tool.checkArray(row)
|
||||
}
|
||||
n();
|
||||
});
|
||||
})
|
||||
.post('/addlocation', (req, res, n) => {
|
||||
if (!config.permission.wristband) return n('ERR9000');
|
||||
if (!tool.checkPermission(req)) return n('ERR9000');
|
||||
})
|
||||
.all('*', rt.send);
|
||||
|
||||
module.exports = router;
|
||||
Reference in New Issue
Block a user