trainmodel.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. place: { type: String, required: false, maxLength: 200 }, // 培训地点
  13. color: { type: String, required: false, maxLength: 200 }, // 计划日历中使用颜色
  14. classnum: { type: [classInfo], required: false, select: true }, // 班级
  15. });
  16. // 全年计划模板表
  17. const TrainmodelSchema = {
  18. total: { type: String, required: false, maxLength: 200 }, // 总人数
  19. day: { type: String, required: false, maxLength: 200 }, // 课程所需天数
  20. color: { type: [String], required: false }, // 默认颜色
  21. planyearid: { type: String, required: true, maxLength: 200 }, // 大批次id
  22. planid: { type: String, required: true, maxLength: 200 }, // 计划id
  23. batchnum: { type: [batchInfo], required: false, select: true }, // 默认期下生成的批次数
  24. stunum: { type: String, required: false, maxLength: 200 }, // 默认每班学生数
  25. carpnum: { type: String, required: false, maxLength: 200 }, // 默认每辆车的学生数
  26. };
  27. const schema = new Schema(TrainmodelSchema, { toJSON: { virtuals: true } });
  28. schema.index({ id: 1 });
  29. schema.plugin(metaPlugin);
  30. module.exports = (app) => {
  31. const { mongoose } = app;
  32. return mongoose.model('Trainmodel', schema, 'trainmodel');
  33. };