trainplan.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. startdate: { type: String, required: false, maxLength: 200 }, // 开始日期
  9. enddate: { 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. color: { type: String, required: false, maxLength: 200 }, // 颜色
  14. });
  15. // 学校信息表
  16. const schInfo = new Schema({
  17. code: { type: String, required: false, maxLength: 200 }, // 学校code
  18. num: { type: String, required: false, maxLength: 200 }, // 人数
  19. });
  20. // 期信息表
  21. const termInfo = new Schema({
  22. term: { type: String, required: false, maxLength: 200 }, // 期数
  23. classnum: { type: String, required: false, maxLength: 200 }, // 班级数
  24. batchnum: { type: [ batchInfo ], select: true }, // 批
  25. });
  26. // 节假日信息表
  27. const festivalInfo = new Schema({
  28. begindate: { type: String, required: false, maxLength: 200 }, // 开始日期
  29. finishdate: { type: String, required: false, maxLength: 200 }, // 结束日期
  30. name: { type: String, required: false, maxLength: 200 }, // 名称
  31. });
  32. // 培训计划表
  33. const TrainplanSchema = {
  34. planyearid: { type: String, required: true, maxLength: 200 }, // 大批次id
  35. year: { type: String, required: true, maxLength: 200 }, // 年份
  36. title: { type: String, required: true, maxLength: 500 }, // 标题
  37. status: { type: String, required: false, maxLength: 200, default: '0' }, // 状态,0-筹备中,1-发布,2-结束
  38. termnum: { type: [ termInfo ], select: true }, // 期
  39. school: { type: [ schInfo ], select: true }, // 学校
  40. festivals: { type: [ festivalInfo ], select: true }, // 节假日
  41. };
  42. const schema = new Schema(TrainplanSchema, { toJSON: { virtuals: true } });
  43. schema.index({ id: 1 });
  44. schema.plugin(metaPlugin);
  45. module.exports = app => {
  46. const { mongoose } = app;
  47. return mongoose.model('Trainplan', schema, 'trainplan');
  48. };