tryLessonApply.js 1.1 KB

12345678910111213141516171819202122232425
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  4. // 试课表申请
  5. const tryLessonApply = {
  6. school_id: { type: String, required: false, zh: '学校id', ref: 'School', getProp: [ 'name' ] }, //
  7. lesson_id: { type: String, required: false, zh: '课程id', ref: 'Lesson', getProp: [ 'title' ] }, //
  8. student_id: { type: String, required: false, zh: '学生id', ref: 'Student', getProp: [ 'name', 'icon', 'level', 'phone' ] }, //
  9. result: { type: String, required: false, default: '0', zh: '审核结果' }, // 0:未审核;1:审核通过;-1审核拒绝
  10. reason: { type: String, required: false, zh: '审核理由' }, //
  11. };
  12. const schema = new Schema(tryLessonApply, { toJSON: { virtuals: true } });
  13. schema.index({ id: 1 });
  14. schema.index({ 'meta.createdAt': 1 });
  15. schema.index({ school_id: 1 });
  16. schema.index({ lesson_id: 1 });
  17. schema.index({ student_id: 1 });
  18. schema.index({ result: 1 });
  19. schema.plugin(metaPlugin);
  20. module.exports = app => {
  21. const { mongoose } = app;
  22. return mongoose.model('TryLessonApply', schema, 'tryLessonApply');
  23. };