Ver código fonte

ques_setting

reloaded 4 anos atrás
pai
commit
b3873bea4f
3 arquivos alterados com 49 adições e 42 exclusões
  1. 44 41
      app/controller/.setting.js
  2. 1 0
      app/model/setting.js
  3. 4 1
      app/service/setting.js

+ 44 - 41
app/controller/.setting.js

@@ -1,62 +1,65 @@
 module.exports = {
   create: {
     requestBody: [
-      'planyearid',
-      'planid',
-      'termid',
-      'user_email',
-      'auth_code',
-      'am_start',
-      'am_end',
-      'pm_start',
-      'pm_end',
-      'bd_start',
-      'bd_end'
-    ]
+      "planyearid",
+      "planid",
+      "termid",
+      "user_email",
+      "auth_code",
+      "am_start",
+      "am_end",
+      "pm_start",
+      "pm_end",
+      "bd_start",
+      "bd_end",
+      "ques_setting",
+    ],
   },
   destroy: {
-    params: ['!id'],
-    service: 'delete'
+    params: ["!id"],
+    service: "delete",
   },
   update: {
-    params: ['!id'],
+    params: ["!id"],
     requestBody: [
-      'planyearid',
-      'planid',
-      'termid',
-      'user_email',
-      'auth_code',
-      'am_start',
-      'am_end',
-      'pm_start',
-      'pm_end',
-      'bd_start',
-      'bd_end'
-    ]
+      "planyearid",
+      "planid",
+      "termid",
+      "user_email",
+      "auth_code",
+      "am_start",
+      "am_end",
+      "pm_start",
+      "pm_end",
+      "bd_start",
+      "bd_end",
+      "ques_setting",
+    ],
   },
   show: {
     parameters: {
-      params: ['!id']
+      params: ["!id"],
     },
-    service: 'fetch'
+    service: "fetch",
   },
   index: {
     parameters: {
       query: {
-        planyearid: 'planyearid',
-        planid: 'planid',
-        termid: 'termid',
-        user_email: 'user_email',
-        auth_code: 'auth_code',
-        am_start: 'am_start'
-      }
+        planyearid: "planyearid",
+        planid: "planid",
+        termid: "termid",
+        user_email: "user_email",
+        auth_code: "auth_code",
+        am_start: "am_start",
+        ques_setting: "ques_setting",
+      },
     },
-    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/setting.js

@@ -15,6 +15,7 @@ const SettingSchema = {
   pm_end: { type: String, required: false, maxLength: 20 }, // 下午结束时间
   bd_start: { type: String, required: false, maxLength: 20 }, // 寝室开始时间
   bd_end: { type: String, required: false, maxLength: 20 }, // 寝室结束时间
+  ques_setting: { type: [ Object ], required: false, maxLength: 1000 }, // 问卷设置默认导出字段
 };
 
 

+ 4 - 1
app/service/setting.js

@@ -17,7 +17,7 @@ class SettingService extends CrudService {
     return await this.model.findOne();
   }
 
-  async update({ id }, { planyearid, planid, termid, user_email, auth_code, am_start, am_end, pm_start, pm_end, bd_start, bd_end }) {
+  async update({ id }, { planyearid, planid, termid, user_email, auth_code, am_start, am_end, pm_start, pm_end, bd_start, bd_end,ques_setting }) {
     assert(id, '缺少部分信息项');
     const setting = await this.model.findById(id);
     if (!setting) {
@@ -56,6 +56,9 @@ class SettingService extends CrudService {
     if (bd_end) {
       setting.bd_end = bd_end;
     }
+    if (ques_setting) {
+      setting.ques_setting = ques_setting;
+    }
     await setting.save();
     return setting;
   }