trainplan.js 3.6 KB

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