reloaded 4 éve
szülő
commit
797f66cc3b

+ 3 - 0
app/controller/.uploadquestion.js

@@ -1,6 +1,7 @@
 module.exports = {
   create: {
     requestBody: [
+      'planid',
       '!termid',
       '!batchid',
       '!classid',
@@ -16,6 +17,7 @@ module.exports = {
   update: {
     params: ['!id'],
     requestBody: [
+      'planid',
       'termid',
       'batchid',
       'classid',
@@ -33,6 +35,7 @@ module.exports = {
   index: {
     parameters: {
       query: {
+        planid:"planid",
         termid : 'termid',
         batchid: 'batchid',
         classid : 'classid',

+ 5 - 0
app/controller/uploadquestion.js

@@ -19,6 +19,11 @@ class UploadquestionController extends Controller {
     this.ctx.ok({ ...res });
   }
 
+  async index() {
+    const res = await this.service.query(this.ctx.query);
+    this.ctx.ok({ ...res });
+  }
+
 }
 
 module.exports = CrudController(UploadquestionController, meta);

+ 1 - 0
app/model/uploadquestion.js

@@ -10,6 +10,7 @@ const answerInfo = new Schema({
 
 // 学生上传问卷表
 const UploadquestionSchema = {
+  planid: { type: String, required: true, maxLength: 200 }, // 计划id
   termid: { type: String, required: true, maxLength: 200 }, // 期id
   batchid: { type: String, required: true, maxLength: 200 }, // 批次id
   classid: { type: String, required: true, maxLength: 200 }, // 班级id

+ 13 - 0
app/service/uploadquestion.js

@@ -85,6 +85,19 @@ class UploadquestionService extends CrudService {
     return newdata;
   }
 
+  async query({ skip, limit, ...info }) {
+    const total = await this.model.count(info);
+    const res = await this.model.find(info).skip(Number(skip)).limit(Number(limit));
+    const data = [];
+    for (const _res of res) {
+      const elm = _.cloneDeep(JSON.parse(JSON.stringify(_res)));
+      const stu = await this.smodel.findById(elm.studentid);
+      elm.studentname = stu.name;
+      data.push(elm);
+    }
+    return { data, total };
+  }
+
 }
 
 module.exports = UploadquestionService;