diff --git a/project/controller/backLoginforCtrl.js b/project/controller/backLoginforCtrl.js index 46baf71e1fa32df5f9650c2f0ef17e3da9f0a871..e6eef3f250430e5351ba23d791c648a8a4e227ca 100644 --- a/project/controller/backLoginforCtrl.js +++ b/project/controller/backLoginforCtrl.js @@ -51,7 +51,6 @@ const backLogCtrl = { let value1=req.query.value1; let value2=req.query.value2; let params = [value1,value2]; - console.log(params); inforModel.displayinfoop4(params) .then((data)=>{ // console.log('查到了'); @@ -60,6 +59,17 @@ const backLogCtrl = { .catch((error) => { console.log(error.message) }) + }, + lognum(req, resp) { + let params = []; + inforModel.lognumdao(params) + .then((data)=>{ + // console.log('查到了'); + resp.send(data) + }) + .catch((error) => { + console.log(error.message) + }) } } diff --git a/project/dao/inforDao.js b/project/dao/inforDao.js index 342f815b9f0ed822de78dc03fca39791eb44d003..04d54ba94a93fd04f78900966117c599e0cff420 100644 --- a/project/dao/inforDao.js +++ b/project/dao/inforDao.js @@ -56,7 +56,27 @@ const inforModel={ }) }) }, + lognumdao(params){ + return new Promise((resolve,reject)=>{ + dbpool.connect(` + SELECT + (SELECT COUNT(login_time) FROM login_log_table WHERE DATE_FORMAT(login_time,'%Y-%m-%d')= DATE_FORMAT(NOW(),'%Y-%m-%d'))AS t, + (SELECT COUNT(login_time) FROM login_log_table WHERE DATE_FORMAT(login_time,'%Y-%m-%d')= DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 1 DAY),'%Y-%m-%d'))AS t1, + (SELECT COUNT(login_time) FROM login_log_table WHERE DATE_FORMAT(login_time,'%Y-%m-%d')= DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 2 DAY),'%Y-%m-%d'))AS t2, + (SELECT COUNT(login_time) FROM login_log_table WHERE DATE_FORMAT(login_time,'%Y-%m-%d')= DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 3 DAY),'%Y-%m-%d')) AS t3, + (SELECT COUNT(login_time) FROM login_log_table WHERE DATE_FORMAT(login_time,'%Y-%m-%d')= DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 4 DAY),'%Y-%m-%d') )AS t4, + (SELECT COUNT(login_time) FROM login_log_table WHERE DATE_FORMAT(login_time,'%Y-%m-%d')= DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 5 DAY),'%Y-%m-%d'))AS t5, + (SELECT COUNT(login_time) FROM login_log_table WHERE DATE_FORMAT(login_time,'%Y-%m-%d')= DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 6 DAY),'%Y-%m-%d'))AS t6 + `,params, (error, data ) => { + if(error){ + reject(error) + }else { + resolve(data) + } + }) + }) + }, }; -module.exports = inforModel; \ No newline at end of file +module.exports = inforModel; diff --git a/project/routes/backLoginfor.js b/project/routes/backLoginfor.js index 40e57df6ae9c4ffd4a302eb640ff614aa13d93dd..9dd5fb46f997a564956d54b2cf88c29082347fb9 100644 --- a/project/routes/backLoginfor.js +++ b/project/routes/backLoginfor.js @@ -8,6 +8,7 @@ router.get('/backLoginforop1',backLogCtrl.logInfoop1); router.get('/backLoginforop2',backLogCtrl.logInfoop2); router.get('/backLoginforop3',backLogCtrl.logInfoop3); router.get('/backLoginforop4',backLogCtrl.logInfoop4); +router.get('/backLognum',backLogCtrl.lognum);