'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin'); // 课程表 const lesson = { school_id: { type: String, required: false, zh: '学校id', ref: 'School', getProp: [ 'name' ] }, // title: { type: String, required: false, zh: '课程标题' }, // time_start: { type: String, required: false, zh: '开始上课时间' }, // time_end: { type: String, required: false, zh: '结束时间' }, // money: { type: Number, zh: '金额' }, limit: { type: Number, zh: '人数上限' }, refund_hour: { type: String, 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(lesson, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.index({ school_id: 1 }); schema.index({ time_start: 1 }); schema.index({ time_end: 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Lesson', schema, 'lesson'); };