trainmodel.js 1.4 KB

1234567891011121314151617181920212223242526272829303132
  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 TrainmodelSchema = {
  11. total: { type: String, required: false, maxLength: 200 }, // 总人数
  12. day: { type: String, required: false, maxLength: 200 }, // 课程所需天数
  13. color: { type: [ String ], required: false }, // 默认颜色
  14. planyearid: { type: String, required: true, maxLength: 200 }, // 大批次id
  15. planid: { type: String, required: true, maxLength: 200 }, // 计划id
  16. batchnum: { type: String, required: false, maxLength: 200 }, // 默认期下生成的批次数
  17. classnum: { type: [ classInfo ], required: false, select: true }, // 默认批次下生成的班级数
  18. stunum: { type: String, required: false, maxLength: 200 }, // 默认每班学生数
  19. carpnum: { type: String, required: false, maxLength: 200 }, // 默认每辆车的学生数
  20. };
  21. const schema = new Schema(TrainmodelSchema, { toJSON: { virtuals: true } });
  22. schema.index({ id: 1 });
  23. schema.plugin(metaPlugin);
  24. module.exports = app => {
  25. const { mongoose } = app;
  26. return mongoose.model('Trainmodel', schema, 'trainmodel');
  27. };