瀏覽代碼

Merge branch 'master' of http://git.cc-lotus.info/new_train/service-center

liuyu 5 年之前
父節點
當前提交
43da48c5fd
共有 6 個文件被更改,包括 66 次插入2 次删除
  1. 7 0
      app/controller/student.js
  2. 7 1
      app/model/teacher.js
  3. 1 0
      app/router.js
  4. 1 0
      app/service/leave.js
  5. 49 0
      app/service/student.js
  6. 1 1
      app/service/uploadquestion.js

+ 7 - 0
app/controller/student.js

@@ -19,6 +19,13 @@ class StudentController extends Controller {
     this.ctx.ok({ ...res });
     this.ctx.ok({ ...res });
   }
   }
 
 
+  // GET
+  // 查询
+  async findbedroom() {
+    const data = await this.service.findbedroom(this.ctx.query);
+    this.ctx.ok({ data });
+  }
+
 }
 }
 
 
 module.exports = CrudController(StudentController, meta);
 module.exports = CrudController(StudentController, meta);

+ 7 - 1
app/model/teacher.js

@@ -3,9 +3,15 @@ const Schema = require('mongoose').Schema;
 const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
 const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
 const { Secret } = require('naf-framework-mongoose/lib/model/schema');
 const { Secret } = require('naf-framework-mongoose/lib/model/schema');
 
 
+// 资料路径详情
+const urlInfo = new Schema({
+  uri: { type: String, required: false, maxLength: 200 }, // 路径
+  name: { type: String, required: false, maxLength: 200 }, // 名称
+});
+
 // 资料信息
 // 资料信息
 const FileInfo = new Schema({
 const FileInfo = new Schema({
-  url: { type: String, required: false, maxLength: 200 }, // 资料地址
+  url: { type: [ urlInfo ], select: true }, // 资料路径
   filename: { type: String, required: false, maxLength: 200 }, // 资料名称
   filename: { type: String, required: false, maxLength: 200 }, // 资料名称
   type: { type: String, required: false, maxLength: 200 }, // 资料类别
   type: { type: String, required: false, maxLength: 200 }, // 资料类别
 });
 });

+ 1 - 0
app/router.js

@@ -33,6 +33,7 @@ module.exports = app => {
   router.get('questionnaire', '/api/train/questionnaire/show/:id', controller.questionnaire.show);
   router.get('questionnaire', '/api/train/questionnaire/show/:id', controller.questionnaire.show);
 
 
   // 学生表设置路由
   // 学生表设置路由
+  router.get('sutdent', '/api/train/student/findbedroom', controller.student.findbedroom);
   router.get('sutdent', '/api/train/student/seek', controller.student.seek);
   router.get('sutdent', '/api/train/student/seek', controller.student.seek);
   router.resources('student', '/api/train/student', controller.student); // index、create、show、destroy
   router.resources('student', '/api/train/student', controller.student); // index、create、show、destroy
   router.post('student', '/api/train/student/update/:id', controller.student.update);
   router.post('student', '/api/train/student/update/:id', controller.student.update);

+ 1 - 0
app/service/leave.js

@@ -46,6 +46,7 @@ class LeaveService extends CrudService {
       leave.reason = reason;
       leave.reason = reason;
     }
     }
     if (status) {
     if (status) {
+      leave.status = status;
       const student = await this.smodel.findById(studentid);
       const student = await this.smodel.findById(studentid);
       const remark = '感谢您的使用';
       const remark = '感谢您的使用';
       const stuuser = await this.umodel.findOne({ uid: studentid, type: '4' });
       const stuuser = await this.umodel.findOne({ uid: studentid, type: '4' });

+ 49 - 0
app/service/student.js

@@ -22,6 +22,55 @@ class StudentService extends CrudService {
     return result;
     return result;
   }
   }
 
 
+  async findbedroom(data) {
+    const { batchid, classid } = data;
+    const result = [];
+    // 如果传的是批次id
+    if (batchid) {
+      // 查询该批次下的所有学生
+      const students = await this.model.find({ batchid });
+      const bedroomList = new Set();
+      // 查询该批次的所有寝室号
+      for (const student of students) {
+        bedroomList.add(student.bedroom);
+      }
+      let studentList = [];
+      // 查询该批次所有寝室下的学生名单
+      for (const bedroom of bedroomList) {
+        const newstudents = await this.model.find({ bedroom });
+        for (const newstudent of newstudents) {
+          studentList.push(newstudent.name);
+        }
+        result.push({ bedroom, studentList });
+        studentList = [];
+      }
+    }
+    // 如果传的是班级id
+    if (classid) {
+      // 查询该班级所有学生
+      const students = await this.model.find({ classid });
+      const bedroomList = new Set();
+      // 查询该班级所有寝室号
+      for (const student of students) {
+        bedroomList.add(student.bedroom);
+      }
+      let studentList = [];
+      // 查询该班级所有寝室的学生名单
+      for (const bedroom of bedroomList) {
+        const newstudents = await this.model.find({ bedroom });
+        for (const newstudent of newstudents) {
+          // 如果寝室中有非本班级学生(混寝),则过滤掉不予显示
+          if (newstudent.classid === classid) {
+            studentList.push(newstudent.name);
+          }
+        }
+        result.push({ bedroom, studentList });
+        studentList = [];
+      }
+    }
+    return result;
+  }
+
 }
 }
 
 
 module.exports = StudentService;
 module.exports = StudentService;

+ 1 - 1
app/service/uploadquestion.js

@@ -63,7 +63,7 @@ class UploadquestionService extends CrudService {
       const stus = await this.smodel.find({ classid: typeid });
       const stus = await this.smodel.find({ classid: typeid });
       for (const elm of stus) {
       for (const elm of stus) {
         // 取得当前期学生答问卷数
         // 取得当前期学生答问卷数
-        const answer = await this.model.find({ studentid: elm.id, questionnaireid });
+        const answer = await this.model.findOne({ studentid: elm.id, questionnaireid });
         let completion = '';
         let completion = '';
         if (answer) {
         if (answer) {
           completion = '100%';
           completion = '100%';