trainplan.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 批次信息表
  5. const batchInfo = new Schema({
  6. batch: { type: String, required: false, maxLength: 200 }, // 批次
  7. class: { type: String, required: false, maxLength: 200 }, // 班级数
  8. begindate: { type: String, required: false, maxLength: 200 }, // 开始日期
  9. finishdate: { type: String, required: false, maxLength: 200 }, // 结束日期
  10. type: { type: String, required: false, maxLength: 200 }, // 类型:0-正常,1-特殊
  11. name: { type: String, required: false, maxLength: 200 }, // 名称
  12. number: { type: String, required: false, maxLength: 200 }, // 人数
  13. });
  14. // 期信息表
  15. const termInfo = new Schema({
  16. term: { type: String, required: false, maxLength: 200 }, // 期数
  17. classnum: { type: String, required: false, maxLength: 200 }, // 班级数
  18. batchnum: { type: [ batchInfo ], select: true }, // 批
  19. });
  20. // 培训计划表
  21. const TrainplanSchema = {
  22. year: { type: String, required: true, maxLength: 200 }, // 年份
  23. title: { type: String, required: true, maxLength: 500 }, // 标题
  24. status: { type: String, required: false, maxLength: 200 }, // 状态,0-筹备中,1-发布,2-结束
  25. termnum: { type: [ termInfo ], select: true }, // 期
  26. };
  27. const schema = new Schema(TrainplanSchema, { toJSON: { virtuals: true } });
  28. schema.index({ id: 1 });
  29. schema.plugin(metaPlugin);
  30. module.exports = app => {
  31. const { mongoose } = app;
  32. return mongoose.model('Trainplan', schema, 'trainplan');
  33. };