tempLessonApply.js 1.3 KB

12345678910111213141516171819202122232425262728
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  4. // 临时上课申请
  5. const tempLessonApply = {
  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' ] }, //
  9. coach_id: { type: String, required: false, zh: '教练id', ref: 'Coach', getProp: [ 'name' ] }, //
  10. result: { type: String, required: false, default: '0', zh: '审核结果' }, // 0:未审核;1:审核通过;-1审核失败
  11. reason: { type: String, required: false, zh: '审核原因' }, //
  12. img_url: { type: Array, required: false, zh: '证据' }, //
  13. };
  14. const schema = new Schema(tempLessonApply, { toJSON: { virtuals: true } });
  15. schema.index({ id: 1 });
  16. schema.index({ 'meta.createdAt': 1 });
  17. schema.index({ school_id: 1 });
  18. schema.index({ lesson_id: 1 });
  19. schema.index({ student_id: 1 });
  20. schema.index({ coach_id: 1 });
  21. schema.index({ result: 1 });
  22. schema.plugin(metaPlugin);
  23. module.exports = app => {
  24. const { mongoose } = app;
  25. return mongoose.model('TempLessonApply', schema, 'tempLessonApply');
  26. };