trainplan.js 3.2 KB

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