From c30dcdad8f176ed535b714a9c67fc3326a3baa33 Mon Sep 17 00:00:00 2001 From: poettt <976172284@qq.com> Date: Mon, 15 Jul 2019 16:05:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90echar=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- project/controller/backLoginforCtrl.js | 12 +++++++++++- project/dao/inforDao.js | 22 +++++++++++++++++++++- project/routes/backLoginfor.js | 1 + 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/project/controller/backLoginforCtrl.js b/project/controller/backLoginforCtrl.js index 46baf71..e6eef3f 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 342f815..04d54ba 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 40e57df..9dd5fb4 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); -- Gitee