trainplan.js 3.7 KB

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