ソースを参照

修改问卷添加接口

liuyu 4 年 前
コミット
b0bea4ad52
1 ファイル変更9 行追加1 行削除
  1. 9 1
      app/service/questionnaire.js

+ 9 - 1
app/service/questionnaire.js

@@ -16,10 +16,18 @@ class QuestionnaireService extends CrudService {
 
   // 插入问卷
   async create(data) {
-    const { name, num, type } = data;
+    const { name, num, type, question } = data;
     assert(name, '问卷名称不能为空');
     assert(num, '问卷序号不能为空');
     assert(type, '问卷类型不能为空');
+    const quedata = [];
+    for (const elm of question) {
+      const ques = await this.questionmodel.findById(elm);
+      if (ques) {
+        quedata.push(ques);
+      }
+    }
+    data.question = quedata;
     return await this.questionnairemodel.create(data);
   }