trainplan.js 2.9 KB

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