lessonStudent.js 1.2 KB

123456789101112131415161718192021222324252627
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  4. // 课程表-学员
  5. const lessonStudent = {
  6. lesson_id: { type: String, required: false, zh: '课程id', ref: 'Lesson', getProp: [ 'name' ] }, //
  7. school_id: { type: String, required: false, zh: '学校id', ref: 'School', getProp: [ 'name' ] }, //
  8. student_id: { type: String, required: false, zh: '学生id', ref: 'Student', getProp: [ 'name' ] }, //
  9. money: { type: String, required: false, zh: '缴费金额' }, //
  10. is_try: { type: String, required: false, default: '0', zh: '是否试课' }, // 0:非试课;1:试课
  11. try_status: { type: String, default: '0', zh: '试课审核状态' }, // 0:未审核;1:审核通过;2审核拒绝
  12. };
  13. const schema = new Schema(lessonStudent, { toJSON: { virtuals: true } });
  14. schema.index({ id: 1 });
  15. schema.index({ 'meta.createdAt': 1 });
  16. schema.index({ lesson_id: 1 });
  17. schema.index({ school_id: 1 });
  18. schema.index({ student_id: 1 });
  19. schema.index({ money: 1 });
  20. schema.index({ is_try: 1 });
  21. schema.plugin(metaPlugin);
  22. module.exports = app => {
  23. const { mongoose } = app;
  24. return mongoose.model('LessonStudent', schema, 'lessonStudent');
  25. };