|
@@ -2,31 +2,26 @@
|
|
|
const Schema = require('mongoose').Schema;
|
|
|
const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
|
|
|
|
|
|
-// 课程表-公开课
|
|
|
-const lessonPublic = {
|
|
|
+// 课程表
|
|
|
+const lesson = {
|
|
|
school_id: { type: String, required: false, zh: '学校id', ref: 'School', getProp: [ 'name' ] }, //
|
|
|
title: { type: String, required: false, zh: '课程标题' }, //
|
|
|
- coach_id: { type: Array, required: false, zh: '教练id' }, //
|
|
|
- limit: { type: Number, required: false, zh: '人数上限' }, //
|
|
|
- student: { type: Array, required: false, zh: '上课学员', ref: 'Student', getProp: [ 'name' ] }, //
|
|
|
time_start: { type: String, required: false, zh: '开始上课时间' }, //
|
|
|
time_end: { type: String, required: false, zh: '结束时间' }, //
|
|
|
- status: { type: String, required: false, zh: '状态' }, // 0-准备中;1-报名中;2-报名结束;3-已开课;4-已结课;-1-停课
|
|
|
+ limit: { type: Number, zh: '人数上限' },
|
|
|
+ type: { type: String, required: false, zh: '课程类型', default: '0' }, // 0:公开课;1私教课
|
|
|
+ status: { type: String, required: false, zh: '状态', default: '0' }, // 0-准备中;1-报名中;2-报名结束;3-已开课;4-已结课;-1-停课
|
|
|
brief: { type: String, required: false, zh: '简介' }, //
|
|
|
};
|
|
|
-const schema = new Schema(lessonPublic, { toJSON: { virtuals: true } });
|
|
|
+const schema = new Schema(lesson, { toJSON: { virtuals: true } });
|
|
|
schema.index({ id: 1 });
|
|
|
schema.index({ 'meta.createdAt': 1 });
|
|
|
schema.index({ school_id: 1 });
|
|
|
-schema.index({ title: 1 });
|
|
|
-schema.index({ coach_id: 1 });
|
|
|
-schema.index({ student: 1 });
|
|
|
schema.index({ time_start: 1 });
|
|
|
schema.index({ time_end: 1 });
|
|
|
-schema.index({ status: 1 });
|
|
|
|
|
|
schema.plugin(metaPlugin);
|
|
|
module.exports = app => {
|
|
|
const { mongoose } = app;
|
|
|
- return mongoose.model('LessonPublic', schema, 'lessonPublic');
|
|
|
+ return mongoose.model('Lesson', schema, 'lesson');
|
|
|
};
|