Commit 8c4186d6 authored by wty's avatar wty

修改埋点记录方式

parent cf125989
const env = 'dev'
const env = 'test'
const getConfig = ()=>{
switch (env){
......
......@@ -5,18 +5,12 @@ const router = express.Router()
router.get('/addMd', async (req, res) => {
const {uid, uname, type, info, timestamp} = req.query
const SQL_query = 'SELECT * FROM md WHERE md_user_id = ? AND md_type = ? AND md_info = ?'
const SQL_add = 'UPDATE md SET md.last_time = ? , md.md_num = md.md_num + 1 WHERE md.md_id = ?'
// const SQL_query = 'SELECT * FROM md WHERE md_user_id = ? AND md_type = ? AND md_info = ?'
// const SQL_add = 'UPDATE md SET md.last_time = ? , md.md_num = md.md_num + 1 WHERE md.md_id = ?'
const SQL_addNew = `INSERT INTO md (md.md_user_id, md.md_user_name, md.md_type, md.md_num, md_info, last_time) VALUES (?,?,?,1,?,?)`
try {
const mdInfo = await query(SQL_query, [uid, type, info])
if (mdInfo.length <= 0) {
const addNewRes = await query(SQL_addNew, [uid, uname, type, info, String(timestamp)])
if (addNewRes['affectedRows'] > 0) res.send({success: true, message: '新增埋点'})
return
}
const addRes = await query(SQL_add, [String(timestamp), mdInfo[0]['md_id']])
if (addRes['affectedRows'] <= 0) throw '未找到埋点:md_id=' + mdInfo[0]['md_id']
res.send({success: true})
} catch (e) {
console.error(e)
......@@ -28,12 +22,12 @@ router.get('/addMd', async (req, res) => {
router.get('/queryAllMd', async (req, res) => {
const SQL = 'SELECT * FROM md'
try {
const mdInfo = await query(SQL,[])
const mdInfo = await query(SQL, [])
res.send({
success: true,
data: mdInfo
})
}catch (e){
} catch (e) {
console.error(e)
res.send({success: false, err: e})
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment