reloaded 5 anni fa
parent
commit
e7466bb4ea

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

@@ -4,6 +4,7 @@ module.exports = {
       'name',
       'number',
       'batch',
+      'type'
     ]
   },
   destroy: {
@@ -16,6 +17,7 @@ module.exports = {
       'name',
       'number',
       'batch',
+      'type'
     ]
   },
   show: {
@@ -30,6 +32,7 @@ module.exports = {
         name: 'name',
         number  :'number',
         batch :'batch',
+        type: 'type'
       }
     },
     service: 'query',

+ 49 - 0
app/controller/.schtime.js

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

+ 46 - 0
app/controller/.teaplan.js

@@ -0,0 +1,46 @@
+module.exports = {
+  create: {
+    requestBody: [
+      '!trainplanid',
+      'nobatchid',
+      'classid',
+      'headteacherid'
+    ]
+  },
+  destroy: {
+    params: ['!id'],
+    service: 'delete'
+  },
+  update: {
+    params: ['!id'],
+    requestBody: [
+      'trainplanid',
+      'nobatchid',
+      'classid',
+      'headteacherid'
+    ]
+  },
+  show: {
+    parameters: {
+      params: ['!id']
+    },
+    service: 'fetch'
+  },
+  index: {
+    parameters: {
+      query: {
+        trainplanid :'trainplanid',
+        nobatchid:'nobatchid',
+        classid :'classid',
+        headteacherid :'headteacherid'
+      }
+    },
+    service: 'query',
+    options: {
+      query: ['skip', 'limit'],
+      sort: ['meta.createdAt'],
+      desc: true,
+      count: true
+    }
+  },
+};

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

@@ -4,7 +4,7 @@ module.exports = {
       '!year',
       '!title',
       'status',
-      'termnum'
+      'termnum',
     ]
   },
   destroy: {
@@ -17,7 +17,7 @@ module.exports = {
       'year',
       'title',
       'status',
-      'termnum'
+      'termnum',
     ]
   },
   show: {
@@ -32,7 +32,7 @@ module.exports = {
         year :'year',
         title :'title',
         status :'status',
-        termnum :'termnum'
+        termnum :'termnum',
       }
     },
     service: 'query',

+ 19 - 0
app/controller/schtime.js

@@ -0,0 +1,19 @@
+'use strict';
+
+const _ = require('lodash');
+const meta = require('./.schtime.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
+
+// 培训计划学校上报时间表管理
+class SchtimeController extends Controller {
+
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.schtime;
+  }
+
+
+}
+
+module.exports = CrudController(SchtimeController, meta);

+ 19 - 0
app/controller/teaplan.js

@@ -0,0 +1,19 @@
+'use strict';
+
+const _ = require('lodash');
+const meta = require('./.teaplan.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
+
+// 班主任全年计划管理
+class TeaplanController extends Controller {
+
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.teaplan;
+  }
+
+
+}
+
+module.exports = CrudController(TeaplanController, meta);

+ 1 - 0
app/model/class.js

@@ -9,6 +9,7 @@ const ClassSchema = {
   batch: { type: String, required: false, maxLength: 200 }, // 批次
   term: { type: String, required: false, maxLength: 200 }, // 期
   headteacherid: { type: String, required: false, maxLength: 200 }, // 班主任id
+  type: { type: String, required: false, maxLength: 200 }, // 类型:0-正常,1-特殊
 };
 
 

+ 1 - 1
app/model/festival.js

@@ -12,7 +12,7 @@ const festivalInfo = new Schema({
 // 节假日表
 const FestivalSchema = {
   year: { type: String, required: true, maxLength: 200 }, // 年份
-  festivals: { type: [ festivalInfo ], select: true }, // 
+  festivals: { type: [ festivalInfo ], select: true }, // 节假日
 };
 
 

+ 28 - 0
app/model/schtime.js

@@ -0,0 +1,28 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
+
+const termInfo = new Schema({
+  termnum: { type: String, required: false, maxLength: 200 }, // 期数
+  termid: { type: String, required: false, maxLength: 200 }, // 期id
+  number: { type: String, required: false, maxLength: 200 }, // 人数
+});
+
+// 培训计划学校上报时间表
+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 }, // 备注
+  term: { type: [ termInfo ], select: true }, // 期
+};
+
+
+const schema = new Schema(SchtimeSchema, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.plugin(metaPlugin);
+
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Schtime', schema, 'schtime');
+};

+ 21 - 0
app/model/teaplan.js

@@ -0,0 +1,21 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+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(数组)
+  classid: { type: String, required: false, maxLength: 200 }, // 班id
+  headteacherid: { type: String, required: false, maxLength: 200 }, // 班主任id
+};
+
+
+const schema = new Schema(TeaplanSchema, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.plugin(metaPlugin);
+
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Teaplan', schema, 'teaplan');
+};

+ 11 - 2
app/model/trainplan.js

@@ -6,11 +6,18 @@ const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
 const batchInfo = new Schema({
   batch: { type: String, required: false, maxLength: 200 }, // 批次
   class: { type: String, required: false, maxLength: 200 }, // 班级数
-  begindate: { type: String, required: false, maxLength: 200 }, // 开始日期
-  finishdate: { type: String, required: false, maxLength: 200 }, // 结束日期
+  startdate: { type: String, required: false, maxLength: 200 }, // 开始日期
+  enddate: { type: String, required: false, maxLength: 200 }, // 结束日期
   type: { type: String, required: false, maxLength: 200 }, // 类型:0-正常,1-特殊
   name: { type: String, required: false, maxLength: 200 }, // 名称
   number: { type: String, required: false, maxLength: 200 }, // 人数
+  color: { type: String, required: false, maxLength: 200 }, // 颜色
+});
+
+// 学校信息表
+const schInfo = new Schema({
+  schid: { type: String, required: false, maxLength: 200 }, // 学校id
+  num: { type: String, required: false, maxLength: 200 }, // 人数
 });
 
 // 期信息表
@@ -18,8 +25,10 @@ const termInfo = new Schema({
   term: { type: String, required: false, maxLength: 200 }, // 期数
   classnum: { type: String, required: false, maxLength: 200 }, // 班级数
   batchnum: { type: [ batchInfo ], select: true }, // 批
+  school: { type: [ schInfo ], select: true }, // 学校
 });
 
+
 // 培训计划表
 const TrainplanSchema = {
   year: { type: String, required: true, maxLength: 200 }, // 年份

+ 8 - 0
app/router.js

@@ -74,4 +74,12 @@ module.exports = app => {
   // 课程表设置路由
   router.resources('lesson', '/api/lesson', controller.lesson); // index、create、show、destroy
   router.post('lesson', '/api/lesson/update/:id', controller.lesson.update);
+
+  // 培训计划学校上报时间表设置路由
+  router.resources('schtime', '/api/schtime', controller.schtime); // index、create、show、destroy
+  router.post('schtime', '/api/schtime/update/:id', controller.schtime.update);
+
+  // 班主任全年计划表设置路由
+  router.resources('teaplan', '/api/teaplan', controller.teaplan); // index、create、show、destroy
+  router.post('teaplan', '/api/teaplan/update/:id', controller.teaplan.update);
 };

+ 19 - 0
app/service/schtime.js

@@ -0,0 +1,19 @@
+'use strict';
+
+
+const assert = require('assert');
+const _ = require('lodash');
+const { ObjectId } = require('mongoose').Types;
+const { CrudService } = require('naf-framework-mongoose/lib/service');
+const { BusinessError, ErrorCode } = require('naf-core').Error;
+
+class SchtimeService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'schtime');
+    this.model = this.ctx.model.Schtime;
+  }
+
+
+}
+
+module.exports = SchtimeService;

+ 17 - 0
app/service/teaplan.js

@@ -0,0 +1,17 @@
+'use strict';
+
+
+const assert = require('assert');
+const _ = require('lodash');
+const { ObjectId } = require('mongoose').Types;
+const { CrudService } = require('naf-framework-mongoose/lib/service');
+const { BusinessError, ErrorCode } = require('naf-core').Error;
+
+class TeaplanService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'teaplan');
+    this.model = this.ctx.model.Teaplan;
+  }
+}
+
+module.exports = TeaplanService;

+ 21 - 2
app/service/trainplan.js

@@ -10,9 +10,28 @@ const { BusinessError, ErrorCode } = require('naf-core').Error;
 class TrainplanService extends CrudService {
   constructor(ctx) {
     super(ctx, 'trainplan');
-    this.model = this.ctx.model.Trainplan;
+    this.tpmodel = this.ctx.model.Trainplan;
+    this.clamodel = this.ctx.model.Class;
   }
 
-}
+//   async create(data) {
+//     const terminfo = await data.termnum;
+//     console.log(terminfo);
+//     const { batchnum: { type, name, number }, term } = terminfo;
+//     console.log(type);
+//     if (type === 1) {
+//       const classdata = { name, number, term, type };
+//       await this.clamodel.create(classdata);
+//     }
+//     if (type === 0) {
+//       for (let i = 0; i < class; i++) {
+//         const name = '第' + term + '期' + batch + '批次' + i + '班';
+//         const classdate = { name, number, term, type, newbatch };
+//         await this.clamodel.create(classdate);
+//       }
+//     }
+//     return this.tpmodel.create(data);
+//   }
+// }
 
 module.exports = TrainplanService;