trainplan.js 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 remarkInfo = new Schema({
  50. month: { type: String, required: false, maxLength: 20 }, // 月份
  51. class: { type: String, required: false, maxLength: 200 }, // 班级
  52. number: { type: String, required: false, maxLength: 200 }, // 数量
  53. });
  54. // 培训计划表
  55. const TrainplanSchema = {
  56. planyearid: { type: String, required: true, maxLength: 200 }, // 大批次id
  57. year: { type: String, required: true, maxLength: 200 }, // 年份
  58. title: { type: String, required: true, maxLength: 500 }, // 标题
  59. status: { type: String, required: false, maxLength: 200, default: '0' }, // 状态,0-筹备中,1-发布,2-结束
  60. termnum: { type: [ termInfo ], select: true }, // 期
  61. remark: { type: [ remarkInfo ], select: true }, // 备注
  62. school: { type: [ schInfo ], select: true }, // 学校
  63. festivals: { type: [ festivalInfo ], select: true }, // 节假日
  64. };
  65. const schema = new Schema(TrainplanSchema, { toJSON: { virtuals: true } });
  66. schema.index({ id: 1 });
  67. schema.plugin(metaPlugin);
  68. module.exports = app => {
  69. const { mongoose } = app;
  70. return mongoose.model('Trainplan', schema, 'trainplan');
  71. };