trainplan.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. schid: { type: String, required: false, maxLength: 200 }, // 学校id
  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. school: { type: [ schInfo ], select: true }, // 学校
  26. });
  27. // 节假日信息表
  28. const festivalInfo = new Schema({
  29. begindate: { type: String, required: false, maxLength: 200 }, // 开始日期
  30. finishdate: { type: String, required: false, maxLength: 200 }, // 结束日期
  31. name: { type: String, required: false, maxLength: 200 }, // 名称
  32. });
  33. // 培训计划表
  34. const TrainplanSchema = {
  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. festivals: { type: [ festivalInfo ], select: true }, // 节假日
  40. };
  41. const schema = new Schema(TrainplanSchema, { toJSON: { virtuals: true } });
  42. schema.index({ id: 1 });
  43. schema.plugin(metaPlugin);
  44. module.exports = app => {
  45. const { mongoose } = app;
  46. return mongoose.model('Trainplan', schema, 'trainplan');
  47. };