mirror of
https://gitee.com/xiongmao1988/rax-medical.git
synced 2025-08-24 13:04:57 +08:00
47 lines
1.6 KiB
JavaScript
47 lines
1.6 KiB
JavaScript
import common from "./common.js";
|
||
const app = common.app;
|
||
const connection = common.connection;
|
||
const m_get = common.m_get;
|
||
const m_add = common.m_add;
|
||
const nowTime = common.nowTime;
|
||
|
||
const getTable = () => app.post('/getaiflag', function (req, res) {
|
||
const database = req.body.database;
|
||
const table = `AIFlagTable`;
|
||
const order = `ID`;
|
||
const Clause = false;
|
||
const start = ~~req.body.start;
|
||
const end = ~~req.body.end;
|
||
connection(database).query(m_get(table, Clause, order, start, end), function (error, results, fields) {
|
||
if (error) {
|
||
console.log(`${nowTime()} 错误:${JSON.stringify(error)}`);
|
||
// connection(database).connect();
|
||
return res.status(500).send(error);
|
||
} else {
|
||
res.send(results);
|
||
}
|
||
});
|
||
});
|
||
|
||
const addTable = () => app.post('/addaiflag', (req, res) => {
|
||
const database = req.body.database;
|
||
const table = `AIFlagTable`;
|
||
const key = 'Flag';
|
||
// `name, region, area, house_type, phone, create_time, remark`;
|
||
const values = Number(req.body.flag) ? 1 : 0; // ai给药 : 人工给药
|
||
// `'${v.name}', '${v.region}', '${v.area}', '${v.house_type}', '${v.phone}', '${nowTime()}', '${remark}'`;
|
||
connection(database).query(m_add(table, key, values), function (error, results, fields) {
|
||
if (error) {
|
||
console.log(`${nowTime()} 错误:${JSON.stringify(error)}`);
|
||
return res.status(500).send(error);
|
||
} else {
|
||
res.send(results);
|
||
}
|
||
});
|
||
})
|
||
|
||
export default {
|
||
getTable,
|
||
addTable
|
||
};
|