Browse Source

admin day count

maguohua 8 years ago
parent
commit
3ed5e10c72
2 changed files with 28 additions and 0 deletions
  1. 27 0
      controller/statis/statis.js
  2. 1 0
      routes/statis.js

+ 27 - 0
controller/statis/statis.js

@@ -4,6 +4,7 @@ import StatisModel from '../../models/statis/statis'
 import UserInfoModel from '../../models/v2/userInfo'
 import OrderModel from '../../models/bos/order'
 import dtime from 'time-formater'
+import AdminModel from '../../models/admin/admin'
 
 class Statis {
 	constructor(){
@@ -90,6 +91,32 @@ class Statis {
 			})
 		}
 	}
+	async adminCount(req, res, next){
+		const date = req.params.date;
+		if (!date) {
+			console.log('参数错误')
+			res.send({
+				status: 0,
+				type: 'ERROR_PARAMS',
+				message: '参数错误'
+			})
+			return
+		}
+		try{
+			const count = await AdminModel.find({registe_time: eval('/^' + date + '/gi')}).count()
+			res.send({
+				status: 1,
+				count,
+			})
+		}catch(err){
+			console.log('获取当天注册管理员人数失败');
+			res.send({
+				status: 0,
+				type: 'ERROR_GET_ADMIN_REGISTE_COUNT',
+				message: '获取当天注册管理员人数失败'
+			})
+		}
+	}
 	async orderCount(req, res, next){
 		const date = req.params.date;
 		if (!date) {

+ 1 - 0
routes/statis.js

@@ -10,5 +10,6 @@ router.get('/api/count', Statis.apiAllCount)
 router.get('/api/all', Statis.allApiRecord)
 router.get('/user/:date/count', Statis.userCount)
 router.get('/order/:date/count', Statis.orderCount)
+router.get('/admin/:date/count', Statis.adminCount)
 
 export default router