瀏覽代碼

更新字段

reloaded 5 年之前
父節點
當前提交
7b733d5059

+ 19 - 30
app/controller/.schtime.js

@@ -1,49 +1,38 @@
 module.exports = {
   create: {
-    requestBody: [
-      '!schid',
-      'year',
-      'planid',
-      'remark',
-      'term'
-    ]
+    requestBody: ["!schid", "year", "planid", "remark", "daterange", "term"],
   },
   destroy: {
-    params: ['!id'],
-    service: 'delete'
+    params: ["!id"],
+    service: "delete",
   },
   update: {
-    params: ['!id'],
-    requestBody: [
-      'schid',
-      'year',
-      'planid',
-      'remark',
-      'term'
-    ]
+    params: ["!id"],
+    requestBody: ["schid", "year", "planid", "remark", "daterange", "term"],
   },
   show: {
     parameters: {
-      params: ['!id']
+      params: ["!id"],
     },
-    service: 'fetch'
+    service: "fetch",
   },
   index: {
     parameters: {
       query: {
-        schid :'schid',
-        year :'year',
-        planid :'planid',
-        remark :'remark',
-        term :'term'
-      }
+        schid: "schid",
+        year: "year",
+        planid: "planid",
+        remark: "remark",
+        daterange: "daterange",
+        term: "term",
+      },
     },
-    service: 'query',
+    service: "query",
     options: {
-      query: ['skip', 'limit'],
-      sort: ['meta.createdAt'],
+      query: ["skip", "limit"],
+      sort: ["meta.createdAt"],
       desc: true,
-      count: true
-    }
+      count: true,
+    },
   },
 };

+ 3 - 3
app/controller/.teaplan.js

@@ -2,7 +2,7 @@ module.exports = {
   create: {
     requestBody: [
       '!trainplanid',
-      'nobatchid',
+      'nomonth',
       'classid',
       'headteacherid'
     ]
@@ -15,7 +15,7 @@ module.exports = {
     params: ['!id'],
     requestBody: [
       'trainplanid',
-      'nobatchid',
+      'nomonth',
       'classid',
       'headteacherid'
     ]
@@ -30,7 +30,7 @@ module.exports = {
     parameters: {
       query: {
         trainplanid :'trainplanid',
-        nobatchid:'nobatchid',
+        nomonth:'nomonth',
         classid :'classid',
         headteacherid :'headteacherid'
       }

+ 4 - 1
app/controller/group.js

@@ -7,7 +7,6 @@ const { CrudController } = require('naf-framework-mongoose/lib/controller');
 
 // 分组管理
 class GroupController extends Controller {
-
   constructor(ctx) {
     super(ctx);
     this.service = this.ctx.service.group;
@@ -28,6 +27,10 @@ class GroupController extends Controller {
     this.ctx.ok({ msg: 'ok', data: res });
   }
 
+  async findbystuid() {
+    const res = await this.service.findbystuid(this.ctx.request.body);
+    this.ctx.ok({ msg: 'ok', data: res });
+  }
 }
 
 module.exports = CrudController(GroupController, meta);

+ 4 - 4
app/controller/teaplan.js

@@ -13,10 +13,10 @@ class TeaplanController extends Controller {
     this.service = this.ctx.service.teaplan;
   }
 
-  async findteacher() {
-    const data = await this.service.findteacher(this.ctx.query);
-    this.ctx.ok({ data });
-  }
+  // async findteacher() {
+  //   const data = await this.service.findteacher(this.ctx.query);
+  //   this.ctx.ok({ data });
+  // }
 
 
 }

+ 4 - 2
app/model/schtime.js

@@ -13,8 +13,10 @@ const termInfo = new Schema({
 const SchtimeSchema = {
   schid: { type: String, required: true, maxLength: 500 }, // 学校id
   year: { type: String, required: false, maxLength: 200 }, // 年份
-  planid: { type: String, requiredl: false, maxLength: 200 }, // 培训计划表id
-  remark: { type: String, requiredl: false, maxLength: 500 }, // 备注
+  planid: { type: String, required: false, maxLength: 200 }, // 培训计划表id
+  remark: { type: String, required: false, maxLength: 500 }, // 备注
+  daterange: { type: [ String ], required: false, maxLength: 500 }, // 学校可以上课时间
+  // 此字段不需要暂时先保留
   term: { type: [ termInfo ], select: true }, // 期
 };
 

+ 1 - 1
app/model/teaplan.js

@@ -5,7 +5,7 @@ const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
 // 班主任全年计划表
 const TeaplanSchema = {
   trainplanid: { type: String, required: true, maxLength: 200 }, // 培训计划表id
-  nobatchid: { type: [ String ], required: false, maxLength: 200 }, // 不能上课的批次id(数组)
+  nomonth: { type: [ String ], required: false, maxLength: 200 }, // 不能上课的月份(数组)
   classid: { type: String, required: false, maxLength: 200 }, // 班id
   headteacherid: { type: String, required: false, maxLength: 200 }, // 班主任id
 };

+ 2 - 1
app/router.js

@@ -79,7 +79,7 @@ module.exports = app => {
   router.post('schtime', '/api/train/schtime/update/:id', controller.schtime.update);
 
   // 班主任全年计划表设置路由
-  router.get('teaplan', '/api/train/teaplan/findteacher', controller.teaplan.findteacher);
+  // router.get('teaplan', '/api/train/teaplan/findteacher', controller.teaplan.findteacher);
   router.resources('teaplan', '/api/train/teaplan', controller.teaplan); // index、create、show、destroy
   router.post('teaplan', '/api/train/teaplan/update/:id', controller.teaplan.update);
 
@@ -98,6 +98,7 @@ module.exports = app => {
   router.post('group', '/api/train/group/insert', controller.group.insert);
   router.post('group', '/api/train/group/exit', controller.group.exit);
   router.post('group', '/api/train/group/sethead', controller.group.sethead);
+  router.post('group', '/api/train/group/findbystuid', controller.group.findbystuid);
 
   // 职责说明表设置路由
   router.resources('duty', '/api/train/duty', controller.duty); // index、create、show、destroy

+ 22 - 1
app/service/group.js

@@ -22,7 +22,10 @@ class GroupService extends CrudService {
       stuids.push(student.stuid);
     }
     if (stuids.includes(stuid)) {
-      throw new BusinessError(ErrorCode.DATA_EXIST, '您已加入该组,请勿重复操作');
+      throw new BusinessError(
+        ErrorCode.DATA_EXIST,
+        '您已加入该组,请勿重复操作'
+      );
     } else {
       group.students.push({ stuid, stuname });
       await group.save();
@@ -61,6 +64,24 @@ class GroupService extends CrudService {
     }
     await student.save();
   }
+
+  async findbystuid(data) {
+    const { stuid } = data;
+    const groups = await this.model.find();
+    let result;
+    for (const group of groups) {
+      const students = group.students;
+      for (const student of students) {
+        if (student.stuid === stuid) {
+          result = group;
+        }
+      }
+    }
+    if (!result) {
+      throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '该学生尚未进组');
+    }
+    return result;
+  }
 }
 
 

+ 22 - 22
app/service/teaplan.js

@@ -14,28 +14,28 @@ class TeaplanService extends CrudService {
     this.hmodel = this.ctx.model.Headteacher;
   }
 
-  async findteacher({ batchid }) {
-    // 查询所有班主任信息
-    const headteachers = await this.hmodel.find();
-    const newheadteachers = [];
-    // 遍历班主任信息
-    for (const headteacher of headteachers) {
-      // 查询某班主任对应的班主任全年计划表
-      const teaplan = await this.model.findOne({ headteacherid: headteacher.id });
-      if (teaplan) {
-        const nobatchids = teaplan.nobatchid;
-        // 如果有对应的全年计划表并且该计划表中的不能上课的批次包含指定批次,则添加status='0'的标记
-        if (nobatchids.includes(batchid)) {
-          newheadteachers.push({ ...JSON.parse(JSON.stringify(headteacher)), status: '0' });
-        } else {
-          newheadteachers.push(headteacher);
-        }
-      } else {
-        newheadteachers.push(headteacher);
-      }
-    }
-    return newheadteachers;
-  }
+  // async findteacher({ batchid }) {
+  //   // 查询所有班主任信息
+  //   const headteachers = await this.hmodel.find();
+  //   const newheadteachers = [];
+  //   // 遍历班主任信息
+  //   for (const headteacher of headteachers) {
+  //     // 查询某班主任对应的班主任全年计划表
+  //     const teaplan = await this.model.findOne({ headteacherid: headteacher.id });
+  //     if (teaplan) {
+  //       const nobatchids = teaplan.nobatchid;
+  //       // 如果有对应的全年计划表并且该计划表中的不能上课的批次包含指定批次,则添加status='0'的标记
+  //       if (nobatchids.includes(batchid)) {
+  //         newheadteachers.push({ ...JSON.parse(JSON.stringify(headteacher)), status: '0' });
+  //       } else {
+  //         newheadteachers.push(headteacher);
+  //       }
+  //     } else {
+  //       newheadteachers.push(headteacher);
+  //     }
+  //   }
+  //   return newheadteachers;
+  // }
 
 }