lrf402788946 há 4 anos atrás
pai
commit
afa6e235dd
3 ficheiros alterados com 22 adições e 31 exclusões
  1. 18 27
      app/controller/.apply.js
  2. 1 0
      app/model/apply.js
  3. 3 4
      app/service/apply.js

+ 18 - 27
app/controller/.apply.js

@@ -1,46 +1,37 @@
 module.exports = {
   create: {
-    requestBody: [
-      '!termid',
-      '!subid',
-      '!teacherid',
-      'reason'
-    ]
+    requestBody: ["!termid", "!subid", "!teacherid", "date", "reason"],
   },
   destroy: {
-    params: ['!id'],
-    service: 'delete'
+    params: ["!id"],
+    service: "delete",
   },
   update: {
-    params: ['!id'],
-    requestBody: [
-      'termid',
-      'subid',
-      'teacherid',
-      'reason'
-    ]
+    params: ["!id"],
+    requestBody: ["termid", "subid", "teacherid", "date", "reason"],
   },
   show: {
     parameters: {
-      params: ['!id']
+      params: ["!id"],
     },
-    service: 'fetch'
+    service: "fetch",
   },
   index: {
     parameters: {
       query: {
-        termid :'termid',
-        subid :'subid',
-        teacherid :'teacherid',
-        reason :'reason'
-      }
+        termid: "termid",
+        subid: "subid",
+        date:"date",
+        teacherid: "teacherid",
+        reason: "reason",
+      },
     },
-    service: 'query',
+    service: "query",
     options: {
-      query: ['skip', 'limit'],
-      sort: ['meta.createdAt'],
+      query: ["skip", "limit"],
+      sort: ["meta.createdAt"],
       desc: true,
-      count: true
-    }
+      count: true,
+    },
   },
 };

+ 1 - 0
app/model/apply.js

@@ -6,6 +6,7 @@ const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
 const ApplySchema = {
   termid: { type: String, required: true, maxLength: 200 }, // 申请期id
   subid: { type: String, required: true, maxLength: 200 }, // 科目id
+  date: { type: String, required: true, maxLength: 200 }, // 申请上课的日期
   teacherid: { type: String, required: true, maxLength: 200 }, // 教师id
   reason: { type: String, required: false, maxLength: 2000 }, // 申请原因
 };

+ 3 - 4
app/service/apply.js

@@ -15,10 +15,9 @@ class ApplyService extends CrudService {
   }
 
   // 查询
-  async queryteacher(num) {
-    console.log(num);
-    const { termid, subid } = num;
-    const data = await this.model.find({ termid, subid }).sort({ msscore: -1 });
+  async queryteacher(query) {
+    const { termid, subid, date } = query;
+    const data = await this.model.find({ termid, subid, date }).sort({ msscore: -1 });
     const teachers = [];
     for (const _data of data) {
       const teacherid = _data.teacherid;