trainplan.js 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. reteacher: { type: String, required: false, maxLength: 200 }, // 督导教师
  25. place: { type: String, required: false, maxLength: 200 }, // 培训场地
  26. });
  27. // 学校班级人数信息表
  28. const classNumInfo = new Schema({
  29. name: { type: String, required: false, maxLength: 200 }, // 名称
  30. number: { type: String, required: false, maxLength: 200 }, // 人数
  31. code: { type: String, required: false, maxLength: 200 }, // 班级code
  32. });
  33. // 学校信息表
  34. const schInfo = new Schema({
  35. code: { type: String, required: false, maxLength: 200 }, // 学校code
  36. classnum: { type: [classNumInfo], select: true }, // 班级人数
  37. num: { type: String, required: false, maxLength: 200 }, // 总人数
  38. });
  39. // 期信息表
  40. const termInfo = new Schema({
  41. term: { type: String, required: false, maxLength: 200 }, // 期数
  42. classnum: { type: String, required: false, maxLength: 200 }, // 班级数
  43. batchnum: { type: [batchInfo], select: true }, // 批
  44. placereteacher: { type: Object, required: false }, // 场地对应的督导教师: placeid:teacherName(手写)
  45. reteacher: { type: String, required: false, maxLength: 2000 }, // 督导教师, 根据地点多人所以这里应该有问题
  46. });
  47. // 节假日信息表
  48. const festivalInfo = new Schema({
  49. begindate: { type: String, required: false, maxLength: 200 }, // 开始日期
  50. finishdate: { type: String, required: false, maxLength: 200 }, // 结束日期
  51. name: { type: String, required: false, maxLength: 200 }, // 名称
  52. });
  53. // 备注信息表
  54. const remarkInfo = new Schema({
  55. month: { type: String, required: false, maxLength: 20 }, // 月份
  56. class: { type: String, required: false, maxLength: 200 }, // 班级
  57. number: { type: String, required: false, maxLength: 200 }, // 数量
  58. });
  59. // 培训计划表
  60. const TrainplanSchema = {
  61. planyearid: { type: String, required: true, maxLength: 200 }, // 大批次id
  62. year: { type: String, required: true, maxLength: 200 }, // 年份
  63. title: { type: String, required: true, maxLength: 500 }, // 标题
  64. status: { type: String, required: false, maxLength: 200, default: '0' }, // 状态,0-筹备中,1-发布,2-结束
  65. termnum: { type: [termInfo], select: true }, // 期
  66. remark: { type: [remarkInfo], select: true }, // 备注
  67. school: { type: [schInfo], select: true }, // 学校
  68. festivals: { type: [festivalInfo], select: true }, // 节假日
  69. };
  70. const schema = new Schema(TrainplanSchema, { toJSON: { virtuals: true } });
  71. schema.index({ id: 1 });
  72. schema.plugin(metaPlugin);
  73. module.exports = (app) => {
  74. const { mongoose } = app;
  75. return mongoose.model('Trainplan', schema, 'trainplan');
  76. };