trainmodel.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 期信息表
  5. const classInfo = new Schema({
  6. class: { type: String, required: false, maxLength: 200 }, // 班级名
  7. number: { type: String, required: false, maxLength: 200 }, // 人数
  8. });
  9. // 批次信息表
  10. const batchInfo = new Schema({
  11. batch: { type: String, required: false, maxLength: 200 }, // 批次
  12. classnum: { type: [ classInfo ], required: false, select: true }, // 班级
  13. });
  14. // 全年计划模板表
  15. const TrainmodelSchema = {
  16. total: { type: String, required: false, maxLength: 200 }, // 总人数
  17. day: { type: String, required: false, maxLength: 200 }, // 课程所需天数
  18. color: { type: [ String ], required: false }, // 默认颜色
  19. planyearid: { type: String, required: true, maxLength: 200 }, // 大批次id
  20. planid: { type: String, required: true, maxLength: 200 }, // 计划id
  21. batchnum: { type: [ batchInfo ], required: false, select: true }, // 默认期下生成的批次数
  22. stunum: { type: String, required: false, maxLength: 200 }, // 默认每班学生数
  23. carpnum: { type: String, required: false, maxLength: 200 }, // 默认每辆车的学生数
  24. };
  25. const schema = new Schema(TrainmodelSchema, { toJSON: { virtuals: true } });
  26. schema.index({ id: 1 });
  27. schema.plugin(metaPlugin);
  28. module.exports = app => {
  29. const { mongoose } = app;
  30. return mongoose.model('Trainmodel', schema, 'trainmodel');
  31. };