lessonStudent.js 1.5 KB

12345678910111213141516171819202122232425262728293031
  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. is_pay: { type: String, default: '0', zh: '是否已支付' }, // 0:未支付;1:已支付:-1:支付失败:-2已退款
  13. pay_id: { type: String, required: false, zh: '支付id', ref: 'PayOrder' }, //
  14. config: { type: Array, required: false, zh: '学生与教练关系表的设置快照' }, //
  15. };
  16. const schema = new Schema(lessonStudent, { toJSON: { virtuals: true } });
  17. schema.index({ id: 1 });
  18. schema.index({ 'meta.createdAt': 1 });
  19. schema.index({ lesson_id: 1 });
  20. schema.index({ school_id: 1 });
  21. schema.index({ student_id: 1 });
  22. schema.index({ pay_id: 1 });
  23. schema.index({ is_try: 1 });
  24. schema.index({ is_pay: 1 });
  25. schema.plugin(metaPlugin);
  26. module.exports = app => {
  27. const { mongoose } = app;
  28. return mongoose.model('LessonStudent', schema, 'lessonStudent');
  29. };