trainplan.js 2.5 KB

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