lesson.js 1.5 KB

123456789101112131415161718192021222324252627282930313233
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 课程信息表
  5. const lessonInfo = new Schema({
  6. teaname: { type: String, required: false, maxLength: 500 }, // 教师名称
  7. teaid: { type: String, required: false, maxLength: 500 }, // 教师id
  8. subname: { type: String, required: false, maxLength: 200 }, // 科目名称
  9. subid: { type: String, required: false, maxLength: 200 }, // 科目id
  10. date: { type: String, required: false, maxLength: 500 }, // 日期
  11. time: { type: String, required: false, maxLength: 500 }, // 时间
  12. day: { type: String, required: false, maxLength: 500 }, // 课程天数,半天或一天
  13. reason: { type: String, required: false, maxLength: 500 }, // 原因
  14. });
  15. // 课程表
  16. const LessonSchema = {
  17. classid: { type: String, required: true, maxLength: 500 }, // 班级id
  18. termid: { type: String, required: true, maxLength: 500 }, // 期id
  19. batchid: { type: String, required: true, maxLength: 500 }, // 批次id
  20. lessons: { type: [ lessonInfo ], required: false, select: true }, // 课程信息
  21. status: { type: String, required: false, maxLength: 500, default: '0' }, // 状态:0,未审核;1已通过;改成1的时候需要发送通知
  22. };
  23. const schema = new Schema(LessonSchema, { toJSON: { virtuals: true } });
  24. schema.index({ id: 1 });
  25. schema.plugin(metaPlugin);
  26. module.exports = app => {
  27. const { mongoose } = app;
  28. return mongoose.model('Lesson', schema, 'lesson');
  29. };