lrf 2 years ago
parent
commit
6816d14536

+ 3 - 0
app/controller/config/.statistics.js.js

@@ -71,4 +71,7 @@ module.exports = {
       },
     },
   },
+  studentSign: {
+    requestBody: ['lesson_id', 'student_id', 'range'],
+  },
 };

+ 11 - 0
app/middleware/dealQuery.js

@@ -0,0 +1,11 @@
+'use strict';
+const _ = require('lodash');
+// 将特殊的查询,service返回为{data,total}的情况转换为通常查询结果:即把{}展开
+module.exports = options => {
+  return async function dealquery(ctx, next) {
+    await next();
+    const body = ctx.response.body;
+    const { data, errcode, errmsg } = body;
+    ctx.response.body = { ...data, errcode, errmsg };
+  };
+};

+ 0 - 1
app/service/statistics.js

@@ -308,7 +308,6 @@ class StatisticsService extends CrudService {
 
   async schoolInByLesson({ school_id, time = 'm', skip = 0, limit }) {
     const tq = this.resetQuery(time, 'time_start');
-    console.log(JSON.stringify(tq, null, 1));
     const query = { ...tq, school_id };
     const pipeline = [{ $match: query }];
     const baseCol = { time_start: 1, title: 1 };

+ 2 - 1
app/z_router/statistics.js

@@ -7,7 +7,8 @@ const rkey = 'statistics';
 const ckey = 'statistics';
 const keyZh = '统计';
 const routes = [
-  { method: 'get', path: `${rkey}/schoolInByLesson`, controller: `${ckey}.schoolInByLesson`, name: `${ckey}schoolInByLesson`, zh: `${keyZh}-收入明细` },
+  { method: 'get', path: `${rkey}/studentSign`, controller: `${ckey}.studentSign`, name: `${ckey}studentSign`, zh: `${keyZh}-学员签到情况` },
+  { method: 'get', path: `${rkey}/schoolInByLesson`, middleware: [ 'dealQuery' ], controller: `${ckey}.schoolInByLesson`, name: `${ckey}schoolInByLesson`, zh: `${keyZh}-收入明细` },
   { method: 'get', path: `${rkey}/coachStudentLesson`, controller: `${ckey}.coachStudentLesson`, name: `${ckey}coachStudentLesson`, zh: `${keyZh}-教练,学员情况` },
   { method: 'get', path: `${rkey}/coachLesson`, controller: `${ckey}.coachLesson`, name: `${ckey}coachLesson`, zh: `${keyZh}-教练,授课情况` },
   { method: 'get', path: `${rkey}/studentPay`, controller: `${ckey}.studentPay`, name: `${ckey}studentPay`, zh: `${keyZh}-学员,付费情况` },