trainplan.js 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. name: { type: String, required: false, maxLength: 200 }, // 名称
  7. number: { type: String, required: false, maxLength: 200 }, // 人数
  8. type: { type: String, required: false, maxLength: 200 }, // 类型
  9. hasclass: { type: String, required: false, maxLength: 200 }, // 是否生成班级: 0未生成;1已生成
  10. });
  11. // 批次信息表
  12. const batchInfo = new Schema({
  13. batch: { type: String, required: false, maxLength: 200 }, // 批次
  14. class: { type: [ classInfo ], required: false, select: true }, // 班级数
  15. startdate: { type: String, required: false, maxLength: 200 }, // 开始日期
  16. enddate: { type: String, required: false, maxLength: 200 }, // 结束日期
  17. // type: { type: String, required: false, maxLength: 200 }, // 类型:0-正常,1-特殊
  18. // name: { type: String, required: false, maxLength: 200 }, // 名称
  19. // number: { type: String, required: false, maxLength: 200 }, // 人数
  20. color: { type: String, required: false, maxLength: 200 }, // 颜色
  21. });
  22. // 学校班级人数信息表
  23. const classNumInfo = new Schema({
  24. name: { type: String, required: false, maxLength: 200 }, // 名称
  25. number: { type: String, required: false, maxLength: 200 }, // 人数
  26. code: { type: String, required: false, maxLength: 200 }, // 班级code
  27. });
  28. // 学校信息表
  29. const schInfo = new Schema({
  30. code: { type: String, required: false, maxLength: 200 }, // 学校code
  31. classnum: { type: [ classNumInfo ], select: true }, // 班级人数
  32. num: { type: String, required: false, maxLength: 200 }, // 总人数
  33. });
  34. // 期信息表
  35. const termInfo = new Schema({
  36. term: { type: String, required: false, maxLength: 200 }, // 期数
  37. classnum: { type: String, required: false, maxLength: 200 }, // 班级数
  38. batchnum: { type: [ batchInfo ], select: true }, // 批
  39. });
  40. // 节假日信息表
  41. const festivalInfo = new Schema({
  42. begindate: { type: String, required: false, maxLength: 200 }, // 开始日期
  43. finishdate: { type: String, required: false, maxLength: 200 }, // 结束日期
  44. name: { type: String, required: false, maxLength: 200 }, // 名称
  45. });
  46. // 培训计划表
  47. const TrainplanSchema = {
  48. planyearid: { type: String, required: true, maxLength: 200 }, // 大批次id
  49. year: { type: String, required: true, maxLength: 200 }, // 年份
  50. title: { type: String, required: true, maxLength: 500 }, // 标题
  51. status: { type: String, required: false, maxLength: 200, default: '0' }, // 状态,0-筹备中,1-发布,2-结束
  52. termnum: { type: [ termInfo ], select: true }, // 期
  53. school: { type: [ schInfo ], select: true }, // 学校
  54. festivals: { type: [ festivalInfo ], select: true }, // 节假日
  55. };
  56. const schema = new Schema(TrainplanSchema, { toJSON: { virtuals: true } });
  57. schema.index({ id: 1 });
  58. schema.plugin(metaPlugin);
  59. module.exports = app => {
  60. const { mongoose } = app;
  61. return mongoose.model('Trainplan', schema, 'trainplan');
  62. };